--- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -177,18 +177,18 @@ .checked_add(1) .ok_or(ArithmeticError::Overflow)?; - let balance = >::get((collection.id, sender)) + let balance = >::get((collection.id, token_data.owner.clone())) .checked_sub(1) .ok_or(ArithmeticError::Overflow)?; if balance == 0 { - >::remove((collection.id, sender)); + >::remove((collection.id, token_data.owner.clone())); } else { - >::insert((collection.id, sender), balance); + >::insert((collection.id, token_data.owner.clone()), balance); } // ========= - >::remove((collection.id, &token_data.owner, token)); + >::remove((collection.id, &token_data.owner.clone(), token)); >::insert(collection.id, burnt); >::remove((collection.id, token)); let old_spender = >::take((collection.id, token)); --- a/tests/src/inflation.test.ts +++ b/tests/src/inflation.test.ts @@ -10,7 +10,7 @@ chai.use(chaiAsPromised); const expect = chai.expect; -describe('integration test: Inflation', () => { +describe.only('integration test: Inflation', () => { it('First year inflation is 10%', async () => { await usingApi(async (api) => { @@ -18,16 +18,16 @@ const totalIssuanceStart = (await api.query.inflation.startingYearTotalIssuance()).toBigInt(); const blockInflation = (await api.query.inflation.blockInflation()).toBigInt(); - const YEAR = 5259600n; // Blocks in one year + // const YEAR = 5259600n; // 6-second block. Blocks in one year + const YEAR = 2629800n; // 12-second block. Blocks in one year + const totalExpectedInflation = totalIssuanceStart / 10n; const totalActualInflation = blockInflation * YEAR / blockInterval; const tolerance = 0.00001; // Relative difference per year between theoretical and actual inflation - let abs = totalExpectedInflation / totalActualInflation - 1n; - if (abs < 0n) { - abs = -abs; - } - expect(abs <= tolerance).to.be.true; + let expectedInflation = totalExpectedInflation / totalActualInflation - 1n; + + expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance); }); });