Skip to content

Commit 607048e

Browse files
authored
Merge branch 'master' into jms/v11-updates
2 parents 9dce69f + 465b66e commit 607048e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+318
-109
lines changed

bindings/tests/auction/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
"github.com/rocket-pool/smartnode/bindings/tests/utils"
1617
)
1718

1819
var (
19-
client *ethclient.Client
20+
client *testutils.EthClientWrapper
2021
rp *rocketpool.RocketPool
2122

2223
ownerAccount *accounts.Account
@@ -31,10 +32,11 @@ func TestMain(m *testing.M) {
3132
var err error
3233

3334
// Initialize eth client
34-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
35+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3536
if err != nil {
3637
log.Fatal(err)
3738
}
39+
client = testutils.NewEthClientWrapper(rawClient)
3840

3941
// Initialize contract manager
4042
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/dao/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
"github.com/rocket-pool/smartnode/bindings/tests/utils"
1617
)
1718

1819
var (
19-
client *ethclient.Client
20+
client *testutils.EthClientWrapper
2021
rp *rocketpool.RocketPool
2122

2223
ownerAccount *accounts.Account
@@ -30,10 +31,11 @@ func TestMain(m *testing.M) {
3031
var err error
3132

3233
// Initialize eth client
33-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
34+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3435
if err != nil {
3536
log.Fatal(err)
3637
}
38+
client = testutils.NewEthClientWrapper(rawClient)
3739

3840
// Initialize contract manager
3941
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/dao/trustednode/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
)
1617

1718
var (
18-
client *ethclient.Client
19+
client *testutils.EthClientWrapper
1920
rp *rocketpool.RocketPool
2021

2122
ownerAccount *accounts.Account
@@ -30,10 +31,11 @@ func TestMain(m *testing.M) {
3031
var err error
3132

3233
// Initialize eth client
33-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
34+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3435
if err != nil {
3536
log.Fatal(err)
3637
}
38+
client = testutils.NewEthClientWrapper(rawClient)
3739

3840
// Initialize contract manager
3941
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/deposit/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
)
1617

1718
var (
18-
client *ethclient.Client
19+
client *testutils.EthClientWrapper
1920
rp *rocketpool.RocketPool
2021

2122
ownerAccount *accounts.Account
@@ -27,10 +28,11 @@ func TestMain(m *testing.M) {
2728
var err error
2829

2930
// Initialize eth client
30-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
31+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3132
if err != nil {
3233
log.Fatal(err)
3334
}
35+
client = testutils.NewEthClientWrapper(rawClient)
3436

3537
// Initialize contract manager
3638
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/minipool/contract_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestDetails(t *testing.T) {
8181
}
8282

8383
// Set minipool withdrawable status
84-
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.Address, trustedNodeAccount.GetTransactor()); err != nil {
84+
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.GetAddress(), trustedNodeAccount.GetTransactor()); err != nil {
8585
t.Fatal(err)
8686
}
8787

@@ -136,12 +136,12 @@ func TestDetails(t *testing.T) {
136136
t.Errorf("Incorrect minipool user deposit assigned time %v", user.DepositAssignedTime)
137137
}
138138
}
139-
if withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.Address, nil); err != nil {
139+
if withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.GetAddress(), nil); err != nil {
140140
t.Error(err)
141141
} else {
142142
withdrawalPrefix := byte(1)
143143
padding := make([]byte, 11)
144-
expectedWithdrawalCredentials := bytes.Join([][]byte{{withdrawalPrefix}, padding, mp.Address.Bytes()}, []byte{})
144+
expectedWithdrawalCredentials := bytes.Join([][]byte{{withdrawalPrefix}, padding, mp.GetAddress().Bytes()}, []byte{})
145145
if !bytes.Equal(withdrawalCredentials.Bytes(), expectedWithdrawalCredentials) {
146146
t.Errorf("Incorrect minipool withdrawal credentials %s", hex.EncodeToString(withdrawalCredentials.Bytes()))
147147
}
@@ -228,7 +228,7 @@ func TestStake(t *testing.T) {
228228
if err != nil {
229229
t.Fatal(err)
230230
}
231-
withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.Address, nil)
231+
withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.GetAddress(), nil)
232232
if err != nil {
233233
t.Fatal(err)
234234
}
@@ -345,7 +345,7 @@ func TestClose(t *testing.T) {
345345
}
346346

347347
// Get & check initial minipool exists status
348-
if exists, err := minipool.GetMinipoolExists(rp, mp.Address, nil); err != nil {
348+
if exists, err := minipool.GetMinipoolExists(rp, mp.GetAddress(), nil); err != nil {
349349
t.Error(err)
350350
} else if !exists {
351351
t.Error("Incorrect initial minipool exists status")
@@ -354,7 +354,7 @@ func TestClose(t *testing.T) {
354354
// Simulate a post-merge withdrawal by sending 16 ETH to the minipool
355355
opts := nodeAccount.GetTransactor()
356356
opts.Value = eth.EthToWei(16)
357-
hash, err := eth.SendTransaction(rp.Client, mp.Address, big.NewInt(1337), opts) // Ganache's default chain ID is 1337
357+
hash, err := eth.SendTransaction(rp.Client, mp.GetAddress(), big.NewInt(1337), opts) // Ganache's default chain ID is 1337
358358
if err != nil {
359359
t.Errorf("Error sending ETH to minipool: %s", err.Error())
360360
}
@@ -366,7 +366,7 @@ func TestClose(t *testing.T) {
366366
}
367367

368368
// Get & check updated minipool exists status
369-
if exists, err := minipool.GetMinipoolExists(rp, mp.Address, nil); err != nil {
369+
if exists, err := minipool.GetMinipoolExists(rp, mp.GetAddress(), nil); err != nil {
370370
t.Error(err)
371371
} else if exists {
372372
t.Error("Incorrect updated minipool exists status")
@@ -430,7 +430,7 @@ func TestWithdrawValidatorBalance(t *testing.T) {
430430
}
431431

432432
// Set minipool withdrawable status
433-
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.Address, trustedNodeAccount.GetTransactor()); err != nil {
433+
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.GetAddress(), trustedNodeAccount.GetTransactor()); err != nil {
434434
t.Fatal(err)
435435
}
436436

@@ -443,7 +443,7 @@ func TestWithdrawValidatorBalance(t *testing.T) {
443443
// Withdraw minipool validator balance
444444
opts := swcAccount.GetTransactor()
445445
opts.Value = eth.EthToWei(32)
446-
if _, err := mp.Contract.Transfer(opts); err != nil {
446+
if _, err := mp.GetContract().Transfer(opts); err != nil {
447447
t.Fatal(err)
448448
}
449449

@@ -490,7 +490,7 @@ func TestWithdrawValidatorBalance(t *testing.T) {
490490
}
491491

492492
// Confirm the minipool still exists
493-
if exists, err := minipool.GetMinipoolExists(rp, mp.Address, nil); err != nil {
493+
if exists, err := minipool.GetMinipoolExists(rp, mp.GetAddress(), nil); err != nil {
494494
t.Error(err)
495495
} else if !exists {
496496
t.Error("Minipool no longer exists but it should")
@@ -548,7 +548,7 @@ func TestWithdrawValidatorBalanceAndFinalise(t *testing.T) {
548548
}
549549

550550
// Set minipool withdrawable status
551-
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.Address, trustedNodeAccount.GetTransactor()); err != nil {
551+
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.GetAddress(), trustedNodeAccount.GetTransactor()); err != nil {
552552
t.Fatal(err)
553553
}
554554

@@ -561,7 +561,7 @@ func TestWithdrawValidatorBalanceAndFinalise(t *testing.T) {
561561
// Withdraw minipool validator balance
562562
opts := swcAccount.GetTransactor()
563563
opts.Value = eth.EthToWei(32)
564-
if _, err := mp.Contract.Transfer(opts); err != nil {
564+
if _, err := mp.GetContract().Transfer(opts); err != nil {
565565
t.Fatal(err)
566566
}
567567

@@ -603,7 +603,7 @@ func TestWithdrawValidatorBalanceAndFinalise(t *testing.T) {
603603
}
604604

605605
// Confirm the minipool still exists
606-
if exists, err := minipool.GetMinipoolExists(rp, mp.Address, nil); err != nil {
606+
if exists, err := minipool.GetMinipoolExists(rp, mp.GetAddress(), nil); err != nil {
607607
t.Error(err)
608608
} else if !exists {
609609
t.Error("Minipool doesn't exist but it should")

bindings/tests/minipool/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
)
1617

1718
var (
18-
client *ethclient.Client
19+
client *testutils.EthClientWrapper
1920
rp *rocketpool.RocketPool
2021

2122
ownerAccount *accounts.Account
@@ -29,10 +30,11 @@ func TestMain(m *testing.M) {
2930
var err error
3031

3132
// Initialize eth client
32-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
33+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3334
if err != nil {
3435
log.Fatal(err)
3536
}
37+
client = testutils.NewEthClientWrapper(rawClient)
3638

3739
// Initialize contract manager
3840
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/minipool/minipool_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestMinipoolDetails(t *testing.T) {
7979
}
8080

8181
// Mark minipool as withdrawable
82-
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.Address, trustedNodeAccount.GetTransactor()); err != nil {
82+
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.GetAddress(), trustedNodeAccount.GetTransactor()); err != nil {
8383
t.Fatal(err)
8484
}
8585

@@ -96,7 +96,7 @@ func TestMinipoolDetails(t *testing.T) {
9696
t.Error("Incorrect updated minipool count")
9797
} else {
9898
mpDetails := minipools[0]
99-
if !bytes.Equal(mpDetails.Address.Bytes(), mp.Address.Bytes()) {
99+
if !bytes.Equal(mpDetails.Address.Bytes(), mp.GetAddress().Bytes()) {
100100
t.Errorf("Incorrect minipool address %s", mpDetails.Address.Hex())
101101
}
102102
if !mpDetails.Exists {
@@ -118,7 +118,7 @@ func TestMinipoolDetails(t *testing.T) {
118118
t.Error(err)
119119
} else if len(nodeMinipools) != 1 {
120120
t.Error("Incorrect updated node minipool count")
121-
} else if !bytes.Equal(nodeMinipools[0].Address.Bytes(), mp.Address.Bytes()) {
121+
} else if !bytes.Equal(nodeMinipools[0].Address.Bytes(), mp.GetAddress().Bytes()) {
122122
t.Errorf("Incorrect node minipool address %s", nodeMinipools[0].Address.Hex())
123123
}
124124
if nodeMinipoolPubkeys, err := minipool.GetNodeValidatingMinipoolPubkeys(rp, nodeAccount.Address, nil); err != nil {
@@ -132,7 +132,7 @@ func TestMinipoolDetails(t *testing.T) {
132132
// Get & check minipool address by pubkey
133133
if minipoolAddress, err := minipool.GetMinipoolByPubkey(rp, validatorPubkey, nil); err != nil {
134134
t.Error(err)
135-
} else if !bytes.Equal(minipoolAddress.Bytes(), mp.Address.Bytes()) {
135+
} else if !bytes.Equal(minipoolAddress.Bytes(), mp.GetAddress().Bytes()) {
136136
t.Errorf("Incorrect minipool address %s for pubkey %s", minipoolAddress.Hex(), validatorPubkey.Hex())
137137
}
138138

bindings/tests/minipool/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestSubmitMinipoolWithdrawable(t *testing.T) {
6464
}
6565

6666
// Submit minipool withdrawable status
67-
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.Address, trustedNodeAccount.GetTransactor()); err != nil {
67+
if _, err := minipool.SubmitMinipoolWithdrawable(rp, mp.GetAddress(), trustedNodeAccount.GetTransactor()); err != nil {
6868
t.Fatal(err)
6969
}
7070

bindings/tests/network/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212

1313
"github.com/rocket-pool/smartnode/bindings/tests"
14+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1415
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1516
)
1617

1718
var (
18-
client *ethclient.Client
19+
client *testutils.EthClientWrapper
1920
rp *rocketpool.RocketPool
2021

2122
ownerAccount *accounts.Account
@@ -28,10 +29,11 @@ func TestMain(m *testing.M) {
2829
var err error
2930

3031
// Initialize eth client
31-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
32+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3233
if err != nil {
3334
log.Fatal(err)
3435
}
36+
client = testutils.NewEthClientWrapper(rawClient)
3537

3638
// Initialize contract manager
3739
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

bindings/tests/node/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import (
1010

1111
"github.com/rocket-pool/smartnode/bindings/rocketpool"
1212
"github.com/rocket-pool/smartnode/bindings/tests"
13+
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
1314
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
1415
)
1516

1617
var (
17-
client *ethclient.Client
18+
client *testutils.EthClientWrapper
1819
rp *rocketpool.RocketPool
1920

2021
ownerAccount *accounts.Account
@@ -26,10 +27,11 @@ func TestMain(m *testing.M) {
2627
var err error
2728

2829
// Initialize eth client
29-
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
30+
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
3031
if err != nil {
3132
log.Fatal(err)
3233
}
34+
client = testutils.NewEthClientWrapper(rawClient)
3335

3436
// Initialize contract manager
3537
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))

0 commit comments

Comments
 (0)