-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathgaspump_test.go
60 lines (47 loc) · 1.57 KB
/
gaspump_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 e2e_test
import (
"context"
"math/big"
"testing"
"github.com/omni-network/omni/e2e/app"
"github.com/omni-network/omni/lib/ethclient"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/xchain"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
// TestGasPumps ensures that bridge tests cases defined in e2e/app/gaspump.go were successful.
func TestGasPumps(t *testing.T) {
t.Parallel()
testNetwork(t, func(t *testing.T, network netconf.Network, endpoints xchain.RPCEndpoints) {
t.Helper()
ctx := context.Background()
omniEVM, ok := network.OmniEVMChain()
require.True(t, ok)
omniRPC, err := endpoints.ByNameOrID(omniEVM.Name, omniEVM.ID)
require.NoError(t, err)
omniClient, err := ethclient.Dial(omniEVM.Name, omniRPC)
require.NoError(t, err)
// Sum targetOMNI for each chain / test case pair
// Each test case is run on per chain, except for OmniEVM
totalTargetOMNI := make(map[common.Address]*big.Int)
for _, chain := range network.EVMChains() {
// skip OmniEVM
if chain.ID == omniEVM.ID {
continue
}
for _, test := range app.GasPumpTests {
current, ok := totalTargetOMNI[test.Recipient]
if !ok {
current = big.NewInt(0)
}
totalTargetOMNI[test.Recipient] = new(big.Int).Add(current, test.TargetOMNI)
}
}
for _, test := range app.GasPumpTests {
balance, err := omniClient.BalanceAt(ctx, test.Recipient, nil)
require.NoError(t, err)
require.Equalf(t, totalTargetOMNI[test.Recipient], balance, "recipient: %s", test.Recipient.Hex())
}
})
}