git.delta.rocks / unique-network / refs/commits / 951a40f3c73a

difftreelog

Fix decimals usage

Max Andreev2023-03-30parent: #671f56a.patch.diff
in: master

2 files changed

modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -991,15 +991,15 @@
   const QTZ_MINIMAL_BALANCE_ON_SHIDEN = 1n;
 
   // Quartz -> Shiden
-  const shidenInitialBalance = 1n * SHIDEN_DECIMALS; // 1 SHD, existential deposit required to actually create the account on Shiden
+  const shidenInitialBalance = 1n * (10n ** SHIDEN_DECIMALS); // 1 SHD, existential deposit required to actually create the account on Shiden
   const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?
-  const qtzToShidenTransferred = 10n * QTZ_DECIMALS; // 10 QTZ
+  const qtzToShidenTransferred = 10n * (10n ** QTZ_DECIMALS); // 10 QTZ
   const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens
-  const senderIinitialBalanceQTZ = 100n * QTZ_DECIMALS; // How many QTZ sender has initially
+  const senderIinitialBalanceQTZ = 100n * (10n ** QTZ_DECIMALS); // How many QTZ sender has initially
   const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... QTZ after XCM call
 
   // Shiden -> Quartz
-  const qtzFromShidenTransfered = 5n * QTZ_DECIMALS; // 5 QTZ
+  const qtzFromShidenTransfered = 5n * (10n ** QTZ_DECIMALS); // 5 QTZ
   const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ
 
   before(async () => {
@@ -1183,7 +1183,7 @@
       // Assert: xcQTZ balance correctly decreased
       expect(xcQTZbalance).to.eq(qtzOnShidenLeft);
       // Assert: SDN balance is 0.996...
-      expect(balanceSDN / (SHIDEN_DECIMALS - 3n)).to.eq(996n);
+      expect(balanceSDN / (10n ** (SHIDEN_DECIMALS - 3n))).to.eq(996n);
     });
 
     await helper.wait.newBlocks(3);
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
993 const UNQ_MINIMAL_BALANCE_ON_SHIDEN = 1n;993 const UNQ_MINIMAL_BALANCE_ON_SHIDEN = 1n;
994994
995 // Unique -> Astar995 // Unique -> Astar
996 const astarInitialBalance = 1n * ASTAR_DECIMALS; // 1 ASTR, existential deposit required to actually create the account on Shiden.996 const astarInitialBalance = 1n * (10n ** ASTAR_DECIMALS); // 1 ASTR, existential deposit required to actually create the account on Shiden.
997 const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?997 const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?
998 const unqToAstarTransferred = 10n * UNQ_DECIMALS; // 10 UNQ998 const unqToAstarTransferred = 10n * (10n ** UNQ_DECIMALS); // 10 UNQ
999 const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Shiden takes a commision in foreign tokens999 const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Shiden takes a commision in foreign tokens
1000 const senderIinitialBalanceUNQ = 100n * UNQ_DECIMALS; // How many UNQ sender has initially1000 const senderIinitialBalanceUNQ = 100n * (10n ** UNQ_DECIMALS); // How many UNQ sender has initially
1001 const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... UNQ after XCM call1001 const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... UNQ after XCM call
10021002
1003 // Astar -> Unique1003 // Astar -> Unique
1004 const unqFromAstarTransfered = 5n * UNQ_DECIMALS; // 5 UNQ1004 const unqFromAstarTransfered = 5n * (10n ** UNQ_DECIMALS); // 5 UNQ
1005 const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ1005 const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ
10061006
1007 before(async () => {1007 before(async () => {
1184 // Assert: xcUNQ balance correctly decreased1184 // Assert: xcUNQ balance correctly decreased
1185 expect(xcUNQbalance).to.eq(unqOnAstarLeft);1185 expect(xcUNQbalance).to.eq(unqOnAstarLeft);
1186 // Assert: ASTR balance is 0.996...1186 // Assert: ASTR balance is 0.996...
1187 expect(balanceAstar / (ASTAR_DECIMALS - 3n)).to.eq(996n);1187 expect(balanceAstar / (10n ** (ASTAR_DECIMALS - 3n))).to.eq(996n);
1188 });1188 });
11891189
1190 await helper.wait.newBlocks(3);1190 await helper.wait.newBlocks(3);