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
991 const QTZ_MINIMAL_BALANCE_ON_SHIDEN = 1n;991 const QTZ_MINIMAL_BALANCE_ON_SHIDEN = 1n;
992992
993 // Quartz -> Shiden993 // Quartz -> Shiden
994 const shidenInitialBalance = 1n * SHIDEN_DECIMALS; // 1 SHD, existential deposit required to actually create the account on Shiden994 const shidenInitialBalance = 1n * (10n ** SHIDEN_DECIMALS); // 1 SHD, existential deposit required to actually create the account on Shiden
995 const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?995 const unitsPerSecond = 228_000_000_000n; // This is Phala's value. What will be ours?
996 const qtzToShidenTransferred = 10n * QTZ_DECIMALS; // 10 QTZ996 const qtzToShidenTransferred = 10n * (10n ** QTZ_DECIMALS); // 10 QTZ
997 const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens997 const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens
998 const senderIinitialBalanceQTZ = 100n * QTZ_DECIMALS; // How many QTZ sender has initially998 const senderIinitialBalanceQTZ = 100n * (10n ** QTZ_DECIMALS); // How many QTZ sender has initially
999 const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... QTZ after XCM call999 const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... QTZ after XCM call
10001000
1001 // Shiden -> Quartz1001 // Shiden -> Quartz
1002 const qtzFromShidenTransfered = 5n * QTZ_DECIMALS; // 5 QTZ1002 const qtzFromShidenTransfered = 5n * (10n ** QTZ_DECIMALS); // 5 QTZ
1003 const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ1003 const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ
10041004
1005 before(async () => {1005 before(async () => {
1183 // Assert: xcQTZ balance correctly decreased1183 // Assert: xcQTZ balance correctly decreased
1184 expect(xcQTZbalance).to.eq(qtzOnShidenLeft);1184 expect(xcQTZbalance).to.eq(qtzOnShidenLeft);
1185 // Assert: SDN balance is 0.996...1185 // Assert: SDN balance is 0.996...
1186 expect(balanceSDN / (SHIDEN_DECIMALS - 3n)).to.eq(996n);1186 expect(balanceSDN / (10n ** (SHIDEN_DECIMALS - 3n))).to.eq(996n);
1187 });1187 });
11881188
1189 await helper.wait.newBlocks(3);1189 await helper.wait.newBlocks(3);
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -993,15 +993,15 @@
   const UNQ_MINIMAL_BALANCE_ON_SHIDEN = 1n;
 
   // Unique -> Astar
-  const astarInitialBalance = 1n * ASTAR_DECIMALS; // 1 ASTR, existential deposit required to actually create the account on Shiden.
+  const astarInitialBalance = 1n * (10n ** ASTAR_DECIMALS); // 1 ASTR, 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 unqToAstarTransferred = 10n * UNQ_DECIMALS; // 10 UNQ
+  const unqToAstarTransferred = 10n * (10n ** UNQ_DECIMALS); // 10 UNQ
   const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Shiden takes a commision in foreign tokens
-  const senderIinitialBalanceUNQ = 100n * UNQ_DECIMALS; // How many UNQ sender has initially
+  const senderIinitialBalanceUNQ = 100n * (10n ** UNQ_DECIMALS); // How many UNQ sender has initially
   const senderBalanceAfterXCM = 89_941967662676666465n; // 89.94... UNQ after XCM call
 
   // Astar -> Unique
-  const unqFromAstarTransfered = 5n * UNQ_DECIMALS; // 5 UNQ
+  const unqFromAstarTransfered = 5n * (10n ** UNQ_DECIMALS); // 5 UNQ
   const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ
 
   before(async () => {
@@ -1184,7 +1184,7 @@
       // Assert: xcUNQ balance correctly decreased
       expect(xcUNQbalance).to.eq(unqOnAstarLeft);
       // Assert: ASTR balance is 0.996...
-      expect(balanceAstar / (ASTAR_DECIMALS - 3n)).to.eq(996n);
+      expect(balanceAstar / (10n ** (ASTAR_DECIMALS - 3n))).to.eq(996n);
     });
 
     await helper.wait.newBlocks(3);