From ca4afc4c9e9c14036452666390ae7295c9270748 Mon Sep 17 00:00:00 2001 From: FelixFan1992 Date: Mon, 3 Jun 2024 12:23:50 -0400 Subject: [PATCH] update tests --- .../upkeeps/LinkAvailableBalanceMonitor.sol | 4 +--- .../automation/LinkAvailableBalanceMonitor.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/contracts/src/v0.8/automation/upkeeps/LinkAvailableBalanceMonitor.sol b/contracts/src/v0.8/automation/upkeeps/LinkAvailableBalanceMonitor.sol index 732797fea92..5d8a8d58c8d 100644 --- a/contracts/src/v0.8/automation/upkeeps/LinkAvailableBalanceMonitor.sol +++ b/contracts/src/v0.8/automation/upkeeps/LinkAvailableBalanceMonitor.sol @@ -266,7 +266,6 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter for (uint256 idx = 0; idx < targetAddresses.length; idx++) { address targetAddress = targetAddresses[idx]; contractToFund = s_targets[targetAddress]; - s_targets[targetAddress].lastTopUpTimestamp = uint56(block.timestamp); (bool fundingNeeded, address target) = _needsFunding( targetAddress, @@ -278,13 +277,12 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter bool success = i_linkToken.transfer(target, contractToFund.topUpAmount); if (success) { localBalance -= contractToFund.topUpAmount; + s_targets[targetAddress].lastTopUpTimestamp = uint56(block.timestamp); emit TopUpSucceeded(target, contractToFund.topUpAmount); } else { - s_targets[targetAddress].lastTopUpTimestamp = contractToFund.lastTopUpTimestamp; // should we update this? emit TopUpFailed(targetAddress); } } else { - s_targets[targetAddress].lastTopUpTimestamp = contractToFund.lastTopUpTimestamp; // should we update this? emit TopUpBlocked(targetAddress); } } diff --git a/contracts/test/v0.8/automation/LinkAvailableBalanceMonitor.test.ts b/contracts/test/v0.8/automation/LinkAvailableBalanceMonitor.test.ts index cb9c843c5f4..f63de3498b1 100644 --- a/contracts/test/v0.8/automation/LinkAvailableBalanceMonitor.test.ts +++ b/contracts/test/v0.8/automation/LinkAvailableBalanceMonitor.test.ts @@ -863,6 +863,11 @@ describe('LinkAvailableBalanceMonitor', () => { }) it('should fund the appropriate addresses', async () => { + const ai1 = await labm.getAccountInfo(proxy1.address) + assert.equal(0, ai1.lastTopUpTimestamp.toNumber()) + const ai4 = await labm.getAccountInfo(directTarget1.address) + assert.equal(0, ai4.lastTopUpTimestamp.toNumber()) + const tx = await labm.connect(keeperRegistry).topUp(watchListAddresses) await aggregator1.mock.linkAvailableForPayment.returns(twoLINK) @@ -878,6 +883,8 @@ describe('LinkAvailableBalanceMonitor', () => { (await lt.balanceOf(aggregator1.address)).toBigInt(), twoLINK.toBigInt(), ) + const targetInfo1 = await labm.getAccountInfo(proxy1.address) + assert.notEqual(0, targetInfo1.lastTopUpTimestamp.toNumber()) await expect(tx) .to.emit(labm, 'TopUpSucceeded') .withArgs(aggregator2.address, twoLINK) @@ -891,6 +898,8 @@ describe('LinkAvailableBalanceMonitor', () => { (await lt.balanceOf(directTarget1.address)).toBigInt(), twoLINK.toBigInt(), ) + const targetInfo4 = await labm.getAccountInfo(directTarget1.address) + assert.notEqual(0, targetInfo4.lastTopUpTimestamp.toNumber()) await expect(tx) .to.emit(labm, 'TopUpSucceeded') .withArgs(directTarget2.address, twoLINK) @@ -936,6 +945,9 @@ describe('LinkAvailableBalanceMonitor', () => { await expect(tx) .to.emit(labm, 'TopUpSucceeded') .withArgs(aggregator1.address, oneLINK) + const targetInfo1 = await labm.getAccountInfo(proxy1.address) + assert.notEqual(0, targetInfo1.lastTopUpTimestamp.toNumber()) + await expect(tx) .to.emit(labm, 'TopUpSucceeded') .withArgs(directTarget1.address, oneLINK) @@ -944,6 +956,8 @@ describe('LinkAvailableBalanceMonitor', () => { await expect(tx) .to.emit(labm, 'TopUpBlocked') .withArgs(directTarget2.address) + const targetInfo5 = await labm.getAccountInfo(directTarget2.address) + assert.equal(0, targetInfo5.lastTopUpTimestamp.toNumber()) }) it('should skip an address if the proxy is invalid and it is not a direct target', async () => {