-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulate_e2e_test.go
50 lines (45 loc) · 1.12 KB
/
simulate_e2e_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
package ethutils
import (
"context"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/lmittmann/w3"
)
func TestProvider_SimulateRevertedTx(t *testing.T) {
t.Skip("requires archive node")
p := NewProvider("https://forno.celo.org", CeloMainnet)
type args struct {
txHash common.Hash
blockNumber *big.Int
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "Reverted reason",
args: args{
txHash: w3.H("0x30cc64b374656e517b161bd0d24d5bb401e9b018b30d864f437fa14ac879c1b0"),
blockNumber: big.NewInt(24925269),
},
want: "ERC20: transfer amount exceeds balance",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := p.SimulateRevertedTx(context.Background(), tt.args.txHash, tt.args.blockNumber)
if (err != nil) != tt.wantErr {
t.Errorf("Provider.SimulateRevertedTx() error = %v, wantErr %v, got = %s", err, tt.wantErr, got)
return
}
if got != tt.want {
t.Errorf("Provider.SimulateRevertedTx() = %v, want %v", got, tt.want)
}
t.Log(got)
})
}
}