Skip to content

Commit

Permalink
🚚 [wallet/test,backend/.../wallet] Rename Address -> AddressInWallet
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Geihs <[email protected]>
  • Loading branch information
matthiasgeihs committed Oct 5, 2021
1 parent 9b1b9bd commit 72a972d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
14 changes: 7 additions & 7 deletions backend/ethereum/wallet/hd/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestUnlock(t *testing.T) {
_, err := hdWallet.Unlock(ethwallet.AsWalletAddr(missingAddr))
assert.Error(t, err, "should error on unlocking missing address")

acc, err := hdWallet.Unlock(setup.Address)
acc, err := hdWallet.Unlock(setup.AddressInWallet)
assert.NoError(t, err, "should not error on unlocking valid address")
assert.NotNil(t, acc, "account should be non nil when error is nil")
}
Expand All @@ -99,7 +99,7 @@ func TestContains(t *testing.T) {
missingAddr := common.BytesToAddress(setup.AddressEncoded)
assert.False(t, hdWallet.Contains(missingAddr), "should not contain address of the missing account")

assert.True(t, hdWallet.Contains(ethwallet.AsEthAddr(setup.Address)), "should contain valid account")
assert.True(t, hdWallet.Contains(ethwallet.AsEthAddr(setup.AddressInWallet)), "should contain valid account")
}

// nolint:interfacer // rand.Rand is preferred over io.Reader here.
Expand All @@ -125,10 +125,10 @@ func newSetup(t require.TestingT, prng *rand.Rand) (*test.Setup, accounts.Wallet
require.NoError(t, err, "invalid sample address")

return &test.Setup{
Wallet: hdWallet,
Address: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: sampleBytes,
DataToSign: dataToSign,
Wallet: hdWallet,
AddressInWallet: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: sampleBytes,
DataToSign: dataToSign,
}, rawHDWallet, hdWallet
}
10 changes: 5 additions & 5 deletions backend/ethereum/wallet/keystore/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ func newSetup(t require.TestingT) *test.Setup {
require.NoError(t, err, "decoding valid address should not fail")

return &test.Setup{
Wallet: w,
Address: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: validAddrBytes,
DataToSign: dataToSign,
Wallet: w,
AddressInWallet: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: validAddrBytes,
DataToSign: dataToSign,
}
}

Expand Down
14 changes: 7 additions & 7 deletions backend/ethereum/wallet/simple/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestUnlock(t *testing.T) {
_, err := simpleWallet.Unlock(ethwallet.AsWalletAddr(missingAddr))
assert.Error(t, err, "should error on unlocking missing address")

acc, err := simpleWallet.Unlock(setup.Address)
acc, err := simpleWallet.Unlock(setup.AddressInWallet)
assert.NoError(t, err, "should not error on unlocking missing address")
assert.NotNil(t, acc, "account should be non nil when error is nil")
}
Expand All @@ -69,7 +69,7 @@ func TestWallet_Contains(t *testing.T) {
missingAddr := common.BytesToAddress(setup.AddressEncoded)
assert.False(t, simpleWallet.Contains(missingAddr))

assert.True(t, simpleWallet.Contains(ethwallet.AsEthAddr(setup.Address)))
assert.True(t, simpleWallet.Contains(ethwallet.AsEthAddr(setup.AddressInWallet)))
}

func TestSignatures(t *testing.T) {
Expand Down Expand Up @@ -106,10 +106,10 @@ func newSetup(t require.TestingT, prng *rand.Rand) (*test.Setup, *simple.Wallet)
require.NoError(t, err, "invalid sample address")

return &test.Setup{
Wallet: simpleWallet,
Address: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: validAddrBytes,
DataToSign: dataToSign,
Wallet: simpleWallet,
AddressInWallet: acc.Address(),
Backend: new(ethwallet.Backend),
AddressEncoded: validAddrBytes,
DataToSign: dataToSign,
}, simpleWallet
}
10 changes: 5 additions & 5 deletions backend/sim/wallet/wallet_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func newWalletSetup(rng *rand.Rand) *test.Setup {
}

return &test.Setup{
Backend: new(Backend),
Wallet: w,
Address: acc.Address(),
AddressEncoded: accountB.Address().Bytes(),
DataToSign: data,
Backend: new(Backend),
Wallet: w,
AddressInWallet: acc.Address(),
AddressEncoded: accountB.Address().Bytes(),
DataToSign: data,
}
}
14 changes: 7 additions & 7 deletions wallet/test/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ type UnlockedAccount func() (wallet.Account, error)

// Setup provides all objects needed for the generic tests.
type Setup struct {
Backend wallet.Backend // backend implementation
Wallet wallet.Wallet // the wallet instance used for testing
Address wallet.Address // an address of an account in the test wallet
DataToSign []byte // some data to sign
AddressEncoded []byte // a valid nonzero address not in the wallet
Backend wallet.Backend // backend implementation
Wallet wallet.Wallet // the wallet instance used for testing
AddressInWallet wallet.Address // an address of an account in the test wallet
DataToSign []byte // some data to sign
AddressEncoded []byte // a valid nonzero address not in the wallet
}

// TestAccountWithWalletAndBackend tests an account implementation together with
// a corresponding wallet and backend implementation.
// This function should be called by every implementation of the wallet interface.
func TestAccountWithWalletAndBackend(t *testing.T, s *Setup) {
acc, err := s.Wallet.Unlock(s.Address)
acc, err := s.Wallet.Unlock(s.AddressInWallet)
assert.NoError(t, err)
// Check unlocked account
sig, err := acc.SignData(s.DataToSign)
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestAccountWithWalletAndBackend(t *testing.T, s *Setup) {
// GenericSignatureSizeTest tests that the size of the signatures produced by
// Account.Sign(…) does not vary between executions (tested with 2048 samples).
func GenericSignatureSizeTest(t *testing.T, s *Setup) {
acc, err := s.Wallet.Unlock(s.Address)
acc, err := s.Wallet.Unlock(s.AddressInWallet)
require.NoError(t, err)
// get a signature
sign, err := acc.SignData(s.DataToSign)
Expand Down
4 changes: 2 additions & 2 deletions wallet/test/walletbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func GenericAccountBenchmark(b *testing.B, s *Setup) {
}

func benchAccountSign(b *testing.B, s *Setup) {
perunAcc, err := s.Wallet.Unlock(s.Address)
perunAcc, err := s.Wallet.Unlock(s.AddressInWallet)
require.Nil(b, err)

for n := 0; n < b.N; n++ {
Expand All @@ -50,7 +50,7 @@ func GenericBackendBenchmark(b *testing.B, s *Setup) {
func benchBackendVerifySig(b *testing.B, s *Setup) {
// We dont want to measure the SignDataWithPW here, just need it for the verification
b.StopTimer()
perunAcc, err := s.Wallet.Unlock(s.Address)
perunAcc, err := s.Wallet.Unlock(s.AddressInWallet)
require.Nil(b, err)
signature, err := perunAcc.SignData(s.DataToSign)
require.Nil(b, err)
Expand Down

0 comments on commit 72a972d

Please sign in to comment.