Skip to content

Commit 3c9e9e9

Browse files
authored
fix bug in rekey test. (#3026)
Summary This test has a special handling is case the protocol upgrade completes before we can validate that without an upgrade the rekey feature won't work. However, when that does happen, AccountA is already rekeyed, and would require a different handling. To avoid that while retaining the execution of the test, I've moved the second part to use a different set of accounts. Test Plan This is a test
1 parent 239921a commit 3c9e9e9

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

test/e2e-go/upgrades/rekey_support_test.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,29 @@ func TestRekeyUpgrade(t *testing.T) {
5959
addrB, err := basics.UnmarshalChecksumAddress(accountB)
6060
a.NoError(err)
6161

62+
accountC, err := client.GenerateAddress(wh)
63+
a.NoError(err)
64+
65+
accountD, err := client.GenerateAddress(wh)
66+
a.NoError(err)
67+
68+
addrD, err := basics.UnmarshalChecksumAddress(accountD)
69+
a.NoError(err)
70+
6271
fee := uint64(1000)
6372
amount := uint64(1000000)
6473
lease := [32]byte{}
6574

75+
// move some money from accountA -> accountC
76+
tx, err := client.ConstructPayment(accountA, accountC, fee, amount*10, nil, "", lease, basics.Round(0), basics.Round(0))
77+
a.NoError(err)
78+
79+
fundAccountC, err := client.SignTransactionWithWallet(wh, nil, tx)
80+
a.NoError(err)
81+
82+
_, err = client.BroadcastTransaction(fundAccountC)
83+
a.NoError(err)
84+
6685
curStatus, err := client.Status()
6786
a.NoError(err)
6887
initialStatus := curStatus
@@ -79,11 +98,11 @@ func TestRekeyUpgrade(t *testing.T) {
7998
a.Equal(basics.Address{}, ad.AuthAddr)
8099

81100
// rekey A -> B (RekeyTo check)
82-
tx, err := client.ConstructPayment(accountA, accountB, fee, amount, nil, "", lease, basics.Round(round), basics.Round(initialStatus.NextVersionRound).SubSaturate(1))
101+
tx, err = client.ConstructPayment(accountA, accountB, fee, amount, nil, "", lease, basics.Round(round), basics.Round(initialStatus.NextVersionRound).SubSaturate(1))
83102
a.NoError(err)
84103

85104
tx.RekeyTo = addrB
86-
rekey, err := client.SignTransactionWithWalletAndSigner(wh, nil, "", tx)
105+
rekey, err := client.SignTransactionWithWallet(wh, nil, tx)
87106
a.NoError(err)
88107

89108
_, err = client.BroadcastTransaction(rekey)
@@ -137,12 +156,11 @@ func TestRekeyUpgrade(t *testing.T) {
137156
}
138157

139158
// now that the network already upgraded:
140-
141-
tx, err = client.ConstructPayment(accountA, accountB, fee, amount, nil, "", lease, basics.Round(round), basics.Round(round+1000))
159+
tx, err = client.ConstructPayment(accountC, accountD, fee, amount, nil, "", lease, basics.Round(round), basics.Round(round+1000))
142160
a.NoError(err)
143-
tx.RekeyTo = addrB
161+
tx.RekeyTo = addrD
144162

145-
rekey, err = client.SignTransactionWithWalletAndSigner(wh, nil, "", tx)
163+
rekey, err = client.SignTransactionWithWallet(wh, nil, tx)
146164
a.NoError(err)
147165

148166
// now, that we have upgraded to the new protocol which supports rekey, try again.
@@ -155,7 +173,7 @@ func TestRekeyUpgrade(t *testing.T) {
155173

156174
// use rekeyed key to authorize (AuthAddr check)
157175
tx.RekeyTo = basics.Address{}
158-
rekeyed, err = client.SignTransactionWithWalletAndSigner(wh, nil, accountB, tx)
176+
rekeyed, err = client.SignTransactionWithWalletAndSigner(wh, nil, accountD, tx)
159177
a.NoError(err)
160178

161179
_, err = client.BroadcastTransaction(rekeyed)

0 commit comments

Comments
 (0)