Skip to content

Commit ca3b67b

Browse files
committed
Fix failed QUTIL tests (init fees in state)
1 parent 106d4fe commit ca3b67b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/contracts/QUtil.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,16 @@ struct QUTIL : public ContractBase
12881288
CALL(FinalizeShareholderStateVarProposals, input, output);
12891289
}
12901290

1291+
INITIALIZE()
1292+
{
1293+
// init fee state variables (only called in gtest, because INITIALIZE has been added a long time after IPO)
1294+
state.smt1InvocationFee = QUTIL_STM1_INVOCATION_FEE;
1295+
state.pollCreationFee = QUTIL_POLL_CREATION_FEE;
1296+
state.pollVoteFee = QUTIL_VOTE_FEE;
1297+
state.distributeQuToShareholderFeePerShareholder = QUTIL_DISTRIBUTE_QU_TO_SHAREHOLDER_FEE_PER_SHAREHOLDER;
1298+
state.shareholderProposalFee = 100;
1299+
}
1300+
12911301
BEGIN_EPOCH()
12921302
{
12931303
state.dfMiningSeed = qpi.getPrevSpectrumDigest();

test/contract_qutil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class ContractTestingQUtil : public ContractTesting {
1313
callSystemProcedure(QUTIL_CONTRACT_INDEX, INITIALIZE);
1414
INIT_CONTRACT(QX);
1515
callSystemProcedure(QX_CONTRACT_INDEX, INITIALIZE);
16+
17+
// init fees
18+
callSystemProcedure(QUTIL_CONTRACT_INDEX, INITIALIZE, true);
1619
}
1720

1821
void beginEpoch(bool expectSuccess = true)
@@ -544,7 +547,9 @@ TEST(QUtilTest, VoterListUpdateAndCompaction) {
544547
vote_inputA.address = voterA;
545548
vote_inputA.amount = min_amount;
546549
vote_inputA.chosen_option = 0;
547-
qutil.vote(voterA, vote_inputA, QUTIL_VOTE_FEE);
550+
EXPECT_TRUE(qutil.vote(voterA, vote_inputA, QUTIL_VOTE_FEE).success);
551+
552+
EXPECT_EQ(getBalance(voterA), min_amount + QUTIL_VOTE_FEE);
548553

549554
QUTIL::Vote_input vote_inputB;
550555
vote_inputB.poll_id = poll_id0;

0 commit comments

Comments
 (0)