Skip to content

Commit 8c9ab35

Browse files
committed
fix(): add example
1 parent f3a7c4a commit 8c9ab35

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

example/api_example_test.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package example
22

33
import (
4-
"github.com/everFinance/goar/types"
5-
"io/ioutil"
64
"testing"
75

86
"github.com/everFinance/goar"
@@ -133,30 +131,3 @@ func Test_SendFormatTx(t *testing.T) {
133131
// t.Log("from: ",wallet.Address)
134132
// t.Log("txHash: ", tx.ID)
135133
}
136-
137-
func Test_SendData(t *testing.T) {
138-
arNode := "https://arweave.net"
139-
w, err := goar.NewWalletFromPath("./wallet/account1.json", arNode) // your wallet private key
140-
assert.NoError(t, err)
141-
142-
data, err := ioutil.ReadFile("/Users/sandyzhou/Downloads/abc.jpeg") // local file path
143-
if err != nil {
144-
panic(err)
145-
}
146-
tags := []types.Tag{
147-
{Name: "Sender", Value: "Jie"},
148-
{Name: "Data-Introduce", Value: "Happy anniversary, my google and dearest! I‘m so grateful to have you in my life. I love you to infinity and beyond! (⁎⁍̴̛ᴗ⁍̴̛⁎)"},
149-
}
150-
tx, err := w.SendDataSpeedUp(data, tags, 10)
151-
assert.NoError(t, err)
152-
t.Logf("tx hash: %s", tx.ID)
153-
}
154-
155-
func Test_LoadData(t *testing.T) {
156-
arCli := goar.NewClient("https://arweave.net")
157-
158-
arId := "r90Z_PuhD-louq6uzLTI-xWMfB5TzIti30o7QvW-6A4"
159-
data, err := arCli.GetTransactionData(arId)
160-
assert.NoError(t, err)
161-
t.Log(len(data))
162-
}

example/loacl_data_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package example
2+
3+
import (
4+
"github.com/everFinance/goar"
5+
"github.com/everFinance/goar/types"
6+
"github.com/stretchr/testify/assert"
7+
"io/ioutil"
8+
"testing"
9+
)
10+
11+
func Test_SendData(t *testing.T) {
12+
arNode := "https://arweave.net"
13+
w, err := goar.NewWalletFromPath("./wallet/account1.json", arNode) // your wallet private key
14+
assert.NoError(t, err)
15+
16+
data, err := ioutil.ReadFile("/Users/local/Downloads/abc.jpeg") // local file path
17+
if err != nil {
18+
panic(err)
19+
}
20+
tags := []types.Tag{
21+
{Name: "xxxx", Value: "sssss"},
22+
{Name: "yyyyyy", Value: "kkkkkk"},
23+
}
24+
tx, err := w.SendDataSpeedUp(data, tags, 10)
25+
assert.NoError(t, err)
26+
t.Logf("tx hash: %s", tx.ID)
27+
}
28+
29+
func Test_LoadData(t *testing.T) {
30+
arCli := goar.NewClient("https://arweave.net")
31+
32+
arId := "r90Z_PuhD-louq6uzLTI-xWMfB5TzIti30o7QvW-6A4"
33+
data, err := arCli.GetTransactionData(arId)
34+
assert.NoError(t, err)
35+
t.Log(len(data))
36+
}

0 commit comments

Comments
 (0)