Skip to content

Commit

Permalink
Update account in AccountWithWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed May 15, 2024
1 parent 1d03114 commit db129fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions tools/docker-network/tests/dockertestframework/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ import (
iotago "github.com/iotaledger/iota.go/v4"
)

func (d *DockerTestFramework) ClaimRewardsForValidator(ctx context.Context, validatorWallet *mock.Wallet) {
validatorAccountData := validatorWallet.BlockIssuer.AccountData
func (d *DockerTestFramework) ClaimRewardsForValidator(ctx context.Context, validatorWithWallet *mock.AccountWithWallet) {
wallet := validatorWithWallet.Wallet()
validatorAccountData := validatorWithWallet.Account()
outputData := &mock.OutputData{
ID: validatorAccountData.OutputID,
Address: validatorAccountData.Address,
AddressIndex: validatorAccountData.AddressIndex,
Output: validatorAccountData.Output,
}
signedTx := validatorWallet.ClaimValidatorRewards("", outputData)
signedTx := wallet.ClaimValidatorRewards("", outputData)

validatorWallet.CreateAndSubmitBasicBlock(ctx, "claim_rewards_validator", mock.WithPayload(signedTx))
wallet.CreateAndSubmitBasicBlock(ctx, "claim_rewards_validator", mock.WithPayload(signedTx))
d.AwaitTransactionPayloadAccepted(ctx, signedTx.Transaction.MustID())

// update account data of validator
validatorWallet.SetBlockIssuer(&mock.AccountData{
ID: validatorWallet.BlockIssuer.AccountData.ID,
Address: validatorWallet.BlockIssuer.AccountData.Address,
AddressIndex: validatorWallet.BlockIssuer.AccountData.AddressIndex,
validatorWithWallet.UpdateAccount(&mock.AccountData{
ID: wallet.BlockIssuer.AccountData.ID,
Address: wallet.BlockIssuer.AccountData.Address,
AddressIndex: wallet.BlockIssuer.AccountData.AddressIndex,
OutputID: iotago.OutputIDFromTransactionIDAndIndex(signedTx.Transaction.MustID(), 0),
Output: signedTx.Transaction.Outputs[0].(*iotago.AccountOutput),
})
Expand Down
4 changes: 2 additions & 2 deletions tools/docker-network/tests/rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func Test_ValidatorRewards(t *testing.T) {

// claim rewards that put to the account output
d.AwaitCommitment(validationBlocksEndSlot)
d.ClaimRewardsForValidator(ctx, goodValidator.Wallet())
d.ClaimRewardsForValidator(ctx, lazyValidator.Wallet())
d.ClaimRewardsForValidator(ctx, goodValidator)
d.ClaimRewardsForValidator(ctx, lazyValidator)

// check if the mana increased as expected
goodValidatorFinalMana := goodValidator.Account().Output.StoredMana()
Expand Down

0 comments on commit db129fb

Please sign in to comment.