forked from synapsecns/sanguine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuite_test.go
62 lines (50 loc) · 1.69 KB
/
suite_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
package anvil_test
import (
"testing"
"github.com/ethereum/go-ethereum/common"
. "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/backends/anvil"
"github.com/synapsecns/sanguine/ethergo/example"
"github.com/synapsecns/sanguine/ethergo/example/counter"
"github.com/synapsecns/sanguine/ethergo/manager"
)
var vitalik = common.HexToAddress("0xd8da6bf26964af9d7eed9e03e53415d37aa96045")
type AnvilSuite struct {
*testsuite.TestSuite
backend *anvil.Backend
options *anvil.OptionBuilder
client *anvil.Client
forkAddress string
counter *counter.CounterRef
}
// NewAnvilSuite creates a end-to-end test suite.
func NewAnvilSuite(tb testing.TB) *AnvilSuite {
tb.Helper()
return &AnvilSuite{
TestSuite: testsuite.NewTestSuite(tb),
}
}
func (a *AnvilSuite) SetupSuite() {
a.TestSuite.SetupSuite()
a.forkAddress = core.GetEnv("ETHEREUM_RPC_URI", "https://1rpc.io/eth")
options := anvil.NewAnvilOptionBuilder()
err := options.SetForkURL(a.forkAddress)
Nil(a.T(), err)
// enable otterscan
options.OtterscanEnabled(true)
a.backend = anvil.NewAnvilBackend(a.GetSuiteContext(), a.T(), options)
a.options = options
a.client, err = anvil.Dial(a.GetSuiteContext(), a.backend.RPCAddress())
Nil(a.T(), err)
deployer := manager.NewDeployerManager(a.T(), example.NewCounterDeployer)
deployedContract := deployer.Get(a.GetSuiteContext(), a.backend, example.CounterType)
var ok bool
a.counter, ok = deployedContract.ContractHandle().(*counter.CounterRef)
True(a.T(), ok)
}
func TestAnvilSuite(t *testing.T) {
suite.Run(t, NewAnvilSuite(t))
}