Skip to content

Commit ec1c55e

Browse files
committed
feat(): add some test
1 parent 6642e4e commit ec1c55e

File tree

1 file changed

+66
-5
lines changed

1 file changed

+66
-5
lines changed

example/api_example_test.go

+66-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package example
22

33
import (
4-
"crypto/rand"
5-
"crypto/rsa"
4+
"fmt"
65
"github.com/everFinance/goar/client"
6+
"github.com/everFinance/goar/types"
7+
wallet2 "github.com/everFinance/goar/wallet"
78
"github.com/stretchr/testify/assert"
89
"testing"
10+
"time"
911
)
1012

1113
func Test_Client(t *testing.T) {
@@ -52,12 +54,71 @@ func Test_Client(t *testing.T) {
5254
assert.NoError(t, err)
5355
t.Log(anchor)
5456

55-
// 7. Arql
57+
}
58+
59+
func Test_client2(t *testing.T) {
60+
arNode := "https://arweave.net"
61+
wallet, err := wallet2.NewFromPath("./testKey.json", arNode)
62+
assert.NoError(t, err)
5663

64+
tag := []types.Tag{
65+
types.Tag{
66+
Name: "TokenSymbol",
67+
Value: "DXN",
68+
},
69+
types.Tag{
70+
Name: "Version",
71+
Value: "1.1.0",
72+
},
73+
types.Tag{
74+
Name: "CreatedBy",
75+
Value: "ZYJ123",
76+
},
77+
}
78+
// 连续发送5 笔交易来测试交易打包顺序
79+
for i := 0; i < 5; i++ {
80+
data := fmt.Sprintf("nonce: %d", i)
81+
id, status, err := wallet.SendData([]byte(data), tag)
82+
t.Log(id)
83+
t.Log(status)
84+
t.Log(err)
85+
time.Sleep(30 * time.Second)
86+
}
5787
}
5888

59-
func Test_rsa(t *testing.T) {
60-
privateKey, err := rsa.GenerateKey(rand.Reader, 4096)
89+
func Test_Arq(t *testing.T) {
90+
arqStr := `{
91+
"op": "and",
92+
"expr1": {
93+
"op": "equals",
94+
"expr1": "TokenSymbol",
95+
"expr2": "DXN"
96+
},
97+
"expr2": {
98+
"op": "equals",
99+
"expr1": "CreatedBy",
100+
"expr2": "zhou yu ji"
101+
}
102+
}`
103+
// create client
104+
arNode := "https://arweave.net"
105+
c := client.New(arNode)
106+
ids, err := c.Arql(arqStr)
107+
t.Log(len(ids))
61108
assert.NoError(t, err)
109+
sstr := make([]string, 0)
110+
sstr = append(sstr, "a")
111+
for _, val := range ids {
112+
t.Log(val)
113+
}
62114

115+
// 冒泡排序
116+
for i := 0; i < len(ids); i++ {
117+
for j := 1; j < len(ids)-i; j++ {
118+
if ids[j] > ids[j-1] {
119+
ids[j], ids[j-1] = ids[j-1], ids[j]
120+
}
121+
}
122+
}
123+
t.Log(ids)
63124
}

0 commit comments

Comments
 (0)