Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bindings/tests/auction/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
"github.com/rocket-pool/smartnode/bindings/tests/utils"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/dao/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
"github.com/rocket-pool/smartnode/bindings/tests/utils"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/dao/trustednode/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/deposit/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
26 changes: 13 additions & 13 deletions bindings/tests/minipool/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestDetails(t *testing.T) {
}

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

Expand Down Expand Up @@ -136,12 +136,12 @@ func TestDetails(t *testing.T) {
t.Errorf("Incorrect minipool user deposit assigned time %v", user.DepositAssignedTime)
}
}
if withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.Address, nil); err != nil {
if withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.GetAddress(), nil); err != nil {
t.Error(err)
} else {
withdrawalPrefix := byte(1)
padding := make([]byte, 11)
expectedWithdrawalCredentials := bytes.Join([][]byte{{withdrawalPrefix}, padding, mp.Address.Bytes()}, []byte{})
expectedWithdrawalCredentials := bytes.Join([][]byte{{withdrawalPrefix}, padding, mp.GetAddress().Bytes()}, []byte{})
if !bytes.Equal(withdrawalCredentials.Bytes(), expectedWithdrawalCredentials) {
t.Errorf("Incorrect minipool withdrawal credentials %s", hex.EncodeToString(withdrawalCredentials.Bytes()))
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestStake(t *testing.T) {
if err != nil {
t.Fatal(err)
}
withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.Address, nil)
withdrawalCredentials, err := minipool.GetMinipoolWithdrawalCredentials(rp, mp.GetAddress(), nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestClose(t *testing.T) {
}

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

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

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

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

Expand Down Expand Up @@ -490,7 +490,7 @@ func TestWithdrawValidatorBalance(t *testing.T) {
}

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

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

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

Expand Down Expand Up @@ -603,7 +603,7 @@ func TestWithdrawValidatorBalanceAndFinalise(t *testing.T) {
}

// Confirm the minipool still exists
if exists, err := minipool.GetMinipoolExists(rp, mp.Address, nil); err != nil {
if exists, err := minipool.GetMinipoolExists(rp, mp.GetAddress(), nil); err != nil {
t.Error(err)
} else if !exists {
t.Error("Minipool doesn't exist but it should")
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/minipool/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
8 changes: 4 additions & 4 deletions bindings/tests/minipool/minipool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestMinipoolDetails(t *testing.T) {
}

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

Expand All @@ -96,7 +96,7 @@ func TestMinipoolDetails(t *testing.T) {
t.Error("Incorrect updated minipool count")
} else {
mpDetails := minipools[0]
if !bytes.Equal(mpDetails.Address.Bytes(), mp.Address.Bytes()) {
if !bytes.Equal(mpDetails.Address.Bytes(), mp.GetAddress().Bytes()) {
t.Errorf("Incorrect minipool address %s", mpDetails.Address.Hex())
}
if !mpDetails.Exists {
Expand All @@ -118,7 +118,7 @@ func TestMinipoolDetails(t *testing.T) {
t.Error(err)
} else if len(nodeMinipools) != 1 {
t.Error("Incorrect updated node minipool count")
} else if !bytes.Equal(nodeMinipools[0].Address.Bytes(), mp.Address.Bytes()) {
} else if !bytes.Equal(nodeMinipools[0].Address.Bytes(), mp.GetAddress().Bytes()) {
t.Errorf("Incorrect node minipool address %s", nodeMinipools[0].Address.Hex())
}
if nodeMinipoolPubkeys, err := minipool.GetNodeValidatingMinipoolPubkeys(rp, nodeAccount.Address, nil); err != nil {
Expand All @@ -132,7 +132,7 @@ func TestMinipoolDetails(t *testing.T) {
// Get & check minipool address by pubkey
if minipoolAddress, err := minipool.GetMinipoolByPubkey(rp, validatorPubkey, nil); err != nil {
t.Error(err)
} else if !bytes.Equal(minipoolAddress.Bytes(), mp.Address.Bytes()) {
} else if !bytes.Equal(minipoolAddress.Bytes(), mp.GetAddress().Bytes()) {
t.Errorf("Incorrect minipool address %s for pubkey %s", minipoolAddress.Hex(), validatorPubkey.Hex())
}

Expand Down
2 changes: 1 addition & 1 deletion bindings/tests/minipool/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestSubmitMinipoolWithdrawable(t *testing.T) {
}

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

Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/network/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/node/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (

"github.com/rocket-pool/smartnode/bindings/rocketpool"
"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
4 changes: 2 additions & 2 deletions bindings/tests/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestRegisterNode(t *testing.T) {
}

// Get & check initial node details
if details, err := node.GetNodes(rp, nil); err != nil {
if details, err := node.GetNodes(rp, false, nil); err != nil {
t.Error(err)
} else if len(details) != 0 {
t.Error("Incorrect initial node count")
Expand All @@ -45,7 +45,7 @@ func TestRegisterNode(t *testing.T) {
}

// Get & check updated node details
if details, err := node.GetNodes(rp, nil); err != nil {
if details, err := node.GetNodes(rp, false, nil); err != nil {
t.Error(err)
} else if len(details) != 1 {
t.Error("Incorrect updated node count")
Expand Down
6 changes: 4 additions & 2 deletions bindings/tests/rewards/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/rocket-pool/smartnode/bindings/rocketpool"

"github.com/rocket-pool/smartnode/bindings/tests"
"github.com/rocket-pool/smartnode/bindings/tests/testutils"
"github.com/rocket-pool/smartnode/bindings/tests/testutils/accounts"
)

var (
client *ethclient.Client
client *testutils.EthClientWrapper
rp *rocketpool.RocketPool

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

// Initialize eth client
client, err = ethclient.Dial(tests.Eth1ProviderAddress)
rawClient, err := ethclient.Dial(tests.Eth1ProviderAddress)
if err != nil {
log.Fatal(err)
}
client = testutils.NewEthClientWrapper(rawClient)

// Initialize contract manager
rp, err = rocketpool.NewRocketPool(client, common.HexToAddress(tests.RocketStorageAddress))
Expand Down
Loading
Loading