Skip to content

Commit f7862ca

Browse files
committed
Fix QEarn unit-test with hardcode for epoch 217.
1 parent 9cbd7ed commit f7862ca

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

test/contract_qearn.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class QearnChecker : public QEARN, public QEARN::StateData
161161
}
162162
};
163163

164+
static constexpr uint16 QEARN_RECOVERED_EPOCH = 217;
165+
static constexpr unsigned long long QEARN_RECOVERED_EPOCH_BONUS = 50227542196ULL;
166+
164167
class ContractTestingQearn : protected ContractTesting
165168
{
166169
struct UnlockTableEntry
@@ -331,10 +334,19 @@ class ContractTestingQearn : protected ContractTesting
331334

332335
void simulateDonation(const unsigned long long donationAmount)
333336
{
334-
increaseEnergy(QEARN_CONTRACT_ID, donationAmount);
335-
336337
unsigned long long& totalBonusAmount = allEpochData[system.epoch + 1].bonusAmount;
337-
totalBonusAmount += donationAmount;
338+
339+
unsigned long long amount = donationAmount;
340+
// Epoch 217's bonus is overwritten by Qearn.h's, fund it with
341+
// exactly that value (clamp the accumulated donation)
342+
if (system.epoch + 1 == QEARN_RECOVERED_EPOCH)
343+
{
344+
amount = (totalBonusAmount >= QEARN_RECOVERED_EPOCH_BONUS) ? 0ULL : (QEARN_RECOVERED_EPOCH_BONUS - totalBonusAmount);
345+
}
346+
347+
increaseEnergy(QEARN_CONTRACT_ID, amount);
348+
349+
totalBonusAmount += amount;
338350
if (totalBonusAmount > QEARN_MAX_BONUS_AMOUNT)
339351
totalBonusAmount = QEARN_MAX_BONUS_AMOUNT;
340352
}

0 commit comments

Comments
 (0)