difftreelog
Tests fixed
in: master
2 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth177 .checked_add(1)177 .checked_add(1)178 .ok_or(ArithmeticError::Overflow)?;178 .ok_or(ArithmeticError::Overflow)?;179179180 let balance = <AccountBalance<T>>::get((collection.id, sender))180 let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))181 .checked_sub(1)181 .checked_sub(1)182 .ok_or(ArithmeticError::Overflow)?;182 .ok_or(ArithmeticError::Overflow)?;183183184 if balance == 0 {184 if balance == 0 {185 <AccountBalance<T>>::remove((collection.id, sender));185 <AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));186 } else {186 } else {187 <AccountBalance<T>>::insert((collection.id, sender), balance);187 <AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);188 }188 }189 // =========189 // =========190190191 <Owned<T>>::remove((collection.id, &token_data.owner, token));191 <Owned<T>>::remove((collection.id, &token_data.owner.clone(), token));192 <TokensBurnt<T>>::insert(collection.id, burnt);192 <TokensBurnt<T>>::insert(collection.id, burnt);193 <TokenData<T>>::remove((collection.id, token));193 <TokenData<T>>::remove((collection.id, token));194 let old_spender = <Allowance<T>>::take((collection.id, token));194 let old_spender = <Allowance<T>>::take((collection.id, token));tests/src/inflation.test.tsdiffbeforeafterboth--- 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);
});
});