git.delta.rocks / unique-network / refs/commits / 8f9861a18456

difftreelog

Tests fixed

str-mv2021-11-26parent: #6c1cc7e.patch.diff
in: master

2 files changed

modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
177 .checked_add(1)177 .checked_add(1)
178 .ok_or(ArithmeticError::Overflow)?;178 .ok_or(ArithmeticError::Overflow)?;
179179
180 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)?;
183183
184 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 // =========
190190
191 <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));
modifiedtests/src/inflation.test.tsdiffbeforeafterboth
10chai.use(chaiAsPromised);10chai.use(chaiAsPromised);
11const expect = chai.expect;11const expect = chai.expect;
1212
13describe('integration test: Inflation', () => {13describe.only('integration test: Inflation', () => {
14 it('First year inflation is 10%', async () => {14 it('First year inflation is 10%', async () => {
15 await usingApi(async (api) => {15 await usingApi(async (api) => {
1616
17 const blockInterval = (api.consts.inflation.inflationBlockInterval).toBigInt();17 const blockInterval = (api.consts.inflation.inflationBlockInterval).toBigInt();
18 const totalIssuanceStart = (await api.query.inflation.startingYearTotalIssuance()).toBigInt();18 const totalIssuanceStart = (await api.query.inflation.startingYearTotalIssuance()).toBigInt();
19 const blockInflation = (await api.query.inflation.blockInflation()).toBigInt();19 const blockInflation = (await api.query.inflation.blockInflation()).toBigInt();
2020
21 // const YEAR = 5259600n; // 6-second block. Blocks in one year
21 const YEAR = 5259600n; // Blocks in one year22 const YEAR = 2629800n; // 12-second block. Blocks in one year
23
22 const totalExpectedInflation = totalIssuanceStart / 10n;24 const totalExpectedInflation = totalIssuanceStart / 10n;
23 const totalActualInflation = blockInflation * YEAR / blockInterval;25 const totalActualInflation = blockInflation * YEAR / blockInterval;
2426
25 const tolerance = 0.00001; // Relative difference per year between theoretical and actual inflation27 const tolerance = 0.00001; // Relative difference per year between theoretical and actual inflation
26 let abs = totalExpectedInflation / totalActualInflation - 1n;28 let expectedInflation = totalExpectedInflation / totalActualInflation - 1n;
27 if (abs < 0n) {29
28 abs = -abs;
29 }
30 expect(abs <= tolerance).to.be.true;30 expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance);
31 });31 });
32 });32 });
3333