difftreelog
Merge pull request #248 from UniqueNetwork/fix/develop_tests
in: master
Fix/develop tests
3 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- 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 = <AccountBalance<T>>::get((collection.id, sender))
+ let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))
.checked_sub(1)
.ok_or(ArithmeticError::Overflow)?;
if balance == 0 {
- <AccountBalance<T>>::remove((collection.id, sender));
+ <AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));
} else {
- <AccountBalance<T>>::insert((collection.id, sender), balance);
+ <AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);
}
// =========
- <Owned<T>>::remove((collection.id, &token_data.owner, token));
+ <Owned<T>>::remove((collection.id, &token_data.owner.clone(), token));
<TokensBurnt<T>>::insert(collection.id, burnt);
<TokenData<T>>::remove((collection.id, token));
let old_spender = <Allowance<T>>::take((collection.id, token));
tests/src/approve.test.tsdiffbeforeafterboth24} from './util/helpers';24} from './util/helpers';252526chai.use(chaiAsPromised);26chai.use(chaiAsPromised);27const expect = chai.expect;282729describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {28describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {30 let alice: IKeyringPair;29 let alice: IKeyringPair;tests/src/inflation.test.tsdiffbeforeafterboth--- 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);
});
});