diff --git a/tools/docker-network/tests/dockerframework.go b/tools/docker-network/tests/dockerframework.go index 51e4e2f37..89074a300 100644 --- a/tools/docker-network/tests/dockerframework.go +++ b/tools/docker-network/tests/dockerframework.go @@ -403,11 +403,14 @@ func (d *DockerTestFramework) CreateTaggedDataBlock(issuerID iotago.AccountID, t }, issuerID, congestionResp, issuerResp) } -func (d *DockerTestFramework) SubmitValidationBlock(issuerID iotago.AccountID) *iotago.Block { +func (d *DockerTestFramework) SubmitValidationBlock(issuerID iotago.AccountID, issueNode ...string) *iotago.Block { issuer := d.wallet.Account(issuerID) ctx := context.TODO() issuingTime := time.Now() clt := d.wallet.DefaultClient() + if issueNode != nil { + clt = d.wallet.Clients[issueNode[0]] + } currentSlot := d.wallet.DefaultClient().LatestAPI().TimeProvider().SlotFromTime(issuingTime) apiForSlot := d.wallet.DefaultClient().APIForSlot(currentSlot) diff --git a/tools/docker-network/tests/rewards_test.go b/tools/docker-network/tests/rewards_test.go index 103c9293c..d1ff5a707 100644 --- a/tools/docker-network/tests/rewards_test.go +++ b/tools/docker-network/tests/rewards_test.go @@ -73,8 +73,8 @@ func Test_ValidatorRewards(t *testing.T) { fmt.Println("Wait for ", secToWait, "until expected slot: ", claimingSlot) var wg sync.WaitGroup - issueValidationBlockInBackground(&wg, d, account.ID, currentSlot, claimingSlot, 3, slotsDuration) - issueValidationBlockInBackground(&wg, d, lazyAccount.ID, currentSlot, claimingSlot, 1, slotsDuration) + issueValidationBlockInBackground(&wg, d, account.ID, currentSlot, claimingSlot, 5) + issueValidationBlockInBackground(&wg, d, lazyAccount.ID, currentSlot, claimingSlot, 1) wg.Wait() @@ -241,19 +241,28 @@ func issueCandidacyPayloadInBackground(d *DockerTestFramework, accountID iotago. }() } -func issueValidationBlockInBackground(wg *sync.WaitGroup, d *DockerTestFramework, accountID iotago.AccountID, startSlot, endSlot iotago.SlotIndex, blocksPerSlot int, slotDuration uint8) { +func issueValidationBlockInBackground(wg *sync.WaitGroup, d *DockerTestFramework, accountID iotago.AccountID, startSlot, endSlot iotago.SlotIndex, blocksPerSlot int) { wg.Add(1) go func() { defer wg.Done() fmt.Println("Issuing validation block for account", accountID, "in the background...") defer fmt.Println("Issuing validation block for account", accountID, "in the background......done") + clt := d.wallet.DefaultClient() for i := startSlot; i < endSlot; i++ { + // wait until the slot is reached + for { + if clt.CommittedAPI().TimeProvider().CurrentSlot() == i { + break + } + time.Sleep(2 * time.Second) + } + for range blocksPerSlot { d.SubmitValidationBlock(accountID) + time.Sleep(1 * time.Second) } - time.Sleep(time.Duration(slotDuration) * time.Second) } }() } diff --git a/tools/docker-network/tests/wallet.go b/tools/docker-network/tests/wallet.go index ebb4c3006..28c06c3d9 100644 --- a/tools/docker-network/tests/wallet.go +++ b/tools/docker-network/tests/wallet.go @@ -534,7 +534,7 @@ func (w *DockerWallet) ClaimValidatorRewards(issuerAccountID iotago.AccountID, i }). AddRewardInput(&iotago.RewardInput{Index: 0}, rewardResp.Rewards). AddBlockIssuanceCreditInput(&iotago.BlockIssuanceCreditInput{ - AccountID: accountOutput.AccountID, + AccountID: issuerAccountID, }). AddCommitmentInput(&iotago.CommitmentInput{CommitmentID: lo.Return1(issuerResp.LatestCommitment.ID())}). AddOutput(accountOutput).