-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
60 lines (58 loc) · 1.17 KB
/
main_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
package main
import (
"math/big"
"testing"
)
func TestGetAccountDeltasForBlock(t *testing.T) {
t.Parallel()
data := []struct {
block EthBlock
deltas map[string]*big.Int
err error
}{
{
block: EthBlock{
Number: "0x1",
Miner: "0x2",
GasUsed: "0xabc",
BaseFeePerGas: "0x12abc3",
Txs: []EthTx{
{
From: "0x1",
To: "0x3",
Value: "0x1",
Gas: "0x1",
GasPrice: "0x2",
},
{
From: "0x3",
To: "",
Value: "0x0",
Gas: "0x1",
GasPrice: "0x3",
},
},
},
deltas: map[string]*big.Int{
"0x1": big.NewInt(-3),
"0x3": big.NewInt(-2),
},
},
}
for i, test := range data {
have, err := getAccountDeltasForBlock(test.block)
if err != test.err {
t.Errorf("[Test №%d] expected error '%+v' got '%+v'\n", i, test.err, err)
}
for k, v := range test.deltas {
haveV, ok := have[k]
if !ok {
t.Errorf("[Test №%d] expected to have delta for account %s\n", i, k)
continue
}
if haveV.Cmp(v) != 0 {
t.Errorf("[Test №%d] for account %s expected delta %s, but got %s", i, k, v, haveV)
}
}
}
}