-
Notifications
You must be signed in to change notification settings - Fork 10
/
api_mempool_test.go
90 lines (81 loc) · 2.42 KB
/
api_mempool_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package blockfrost_test
import (
"context"
"path/filepath"
"reflect"
"testing"
"github.com/blockfrost/blockfrost-go"
)
func TestMempoolUnmarshal(t *testing.T) {
want := []blockfrost.Mempool{
{TxHash: "abc"},
{TxHash: "def"},
}
fp := filepath.Join(testdata, "json", "mempool", "mempool.json")
got := []blockfrost.Mempool{}
testStructGotWant(t, fp, &got, &want)
}
func TestMempoolTransactionContentUnmarshal(t *testing.T) {
invalidHereafter := "109798439"
want := blockfrost.MempoolTransactionContent{
Tx: blockfrost.MempoolTransaction{
Hash: "1f96d3824eb2aeeb0b09b99748bb70ac681e0cae6e37e01c43958b79ca69c986",
OutputAmount: []struct {
Quantity string `json:"quantity"`
// The unit of the value
Unit string `json:"unit"`
}{
{
Unit: "lovelace",
Quantity: "2837715",
},
},
Fees: "369133",
Deposit: "0",
Size: 4683,
InvalidBefore: nil,
InvalidHereafter: &invalidHereafter,
UtxoCount: 2,
ValidContract: true,
},
Inputs: []blockfrost.MempoolTransactionInput{{
Address: "addr1vx9wkegx062xmmdzfd69jz6dt48p5mse4v35mml5h6ceznq8ap8fz",
TxHash: "7aa461f4f924586864c74141d457e70cfb26b2b5b9cfea4c5d5580f037ef41da",
OutputIndex: 0,
Collateral: false,
Reference: false,
}},
Outputs: []blockfrost.MempoolTransactionOutput{
{
Address: "addr1vx9wkegx062xmmdzfd69jz6dt48p5mse4v35mml5h6ceznq8ap8fz",
Amount: []blockfrost.TxAmount{{
Unit: "lovelace",
Quantity: "2837715",
}, {
Unit: "6787a47e9f73efe4002d763337140da27afa8eb9a39413d2c39d4286524144546f6b656e73",
Quantity: "15000",
}},
OutputIndex: 0,
DataHash: nil,
InlineDatum: nil,
ReferenceScriptHash: nil,
Collateral: false,
}},
Redeemers: nil,
}
fp := filepath.Join(testdata, "json", "mempool", "transaction.json")
got := blockfrost.MempoolTransactionContent{}
testStructGotWant(t, fp, &got, &want)
}
func TestMempoolIntegration(t *testing.T) {
api := blockfrost.NewAPIClient(blockfrost.APIClientOptions{})
got, err := api.Mempool(context.TODO(), blockfrost.APIQueryParams{})
if err != nil {
t.Fatal(err)
}
var want []blockfrost.Mempool
if reflect.TypeOf(got) != reflect.TypeOf(want) {
t.Fatalf("Expected type []blockfrost.Mempool, got type %T", got)
}
}
// MempoolTx and MempoolByAddress need mocked server to provide static mempool transaction