-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsubmit_test.go
54 lines (50 loc) · 1.42 KB
/
submit_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package arseeding
import (
"github.com/everFinance/goar"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestFetchAndStoreTx(t *testing.T) {
arId := "O3VwBusl0PNKusWcDF44uPt-sNuhywgeKxOmQpDqGc0"
dbPath := "./data/tmp.db"
arNode := "https://arweave.net"
cli := goar.NewClient(arNode)
s, err := NewBoltStore(dbPath)
assert.NoError(t, err)
aa := &Arseeding{store: s, arCli: cli}
err = aa.FetchAndStoreTx(arId)
assert.NoError(t, err)
err = os.RemoveAll(dbPath)
assert.NoError(t, err)
}
func TestSaveSubmitTx(t *testing.T) {
arId := "O3VwBusl0PNKusWcDF44uPt-sNuhywgeKxOmQpDqGc0"
dbPath := "./data/tmp.db"
arNode := "https://arweave.net"
cli := goar.NewClient(arNode)
s, err := NewBoltStore(dbPath)
assert.NoError(t, err)
aa := &Arseeding{store: s, arCli: cli}
tx, err := cli.GetTransactionByID(arId)
assert.NoError(t, err)
err = aa.SaveSubmitTx(*tx)
assert.NoError(t, err)
err = os.RemoveAll(dbPath)
assert.NoError(t, err)
}
func TestSyncAddTxDataEndOffset(t *testing.T) {
arId := "O3VwBusl0PNKusWcDF44uPt-sNuhywgeKxOmQpDqGc0"
dbPath := "./data/tmp.db"
arNode := "https://arweave.net"
cli := goar.NewClient(arNode)
s, err := NewBoltStore(dbPath)
assert.NoError(t, err)
aa := &Arseeding{store: s, arCli: cli}
tx, err := cli.GetTransactionByID(arId)
assert.NoError(t, err)
err = aa.syncAddTxDataEndOffset(tx.DataRoot, tx.DataSize)
assert.NoError(t, err)
err = os.RemoveAll(dbPath)
assert.NoError(t, err)
}