--- 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/approve.test.ts +++ b/tests/src/approve.test.ts @@ -24,7 +24,6 @@ } from './util/helpers'; chai.use(chaiAsPromised); -const expect = chai.expect; describe('Integration Test approve(spender, collection_id, item_id, amount):', () => { let alice: IKeyringPair; --- a/tests/src/inflation.test.ts +++ b/tests/src/inflation.test.ts @@ -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; + const expectedInflation = totalExpectedInflation / totalActualInflation - 1n; + + expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance); }); });