From 44cce9ecf983e288aa306ba84cc1a0fe6bba3082 Mon Sep 17 00:00:00 2001 From: Carlos Flores Date: Tue, 11 Feb 2020 11:04:08 -0800 Subject: [PATCH 1/2] migrateCSaiToDDai and small cDai mint failure --- scripts/test/test.js | 101 +++++++++++++++++++++++++++++++----- scripts/test/testHelpers.js | 1 - 2 files changed, 87 insertions(+), 15 deletions(-) diff --git a/scripts/test/test.js b/scripts/test/test.js index 15bc2a3..6d03178 100644 --- a/scripts/test/test.js +++ b/scripts/test/test.js @@ -6541,18 +6541,70 @@ async function test(testingContext) { assert.strictEqual(walletBalance.cSai, 10.0); await tester.runTest( - "V7 UserSmartWallet relay can trigger cSai to dDai migration", + "V7 UserSmartWallet can get next generic action ID", UserSmartWalletV7, - "migrateCSaiToDDai", - "send", - [], + "getNextGenericActionID", + "call", + [tester.address, "0x", 0], true, - receipt => { - // TODO: verify logs - }, - tester.originalAddress + value => { + genericActionID = value; + } + ); + + let allPreMigrationBalances = await tester.getBalances( + UserSmartWalletV7.options.address ); + let dDaiUnderlyingRaw = web3.utils.toBN( + allPreMigrationBalances.dDaiUnderlyingRaw + ); + let cSaiUnderlyingRaw = web3.utils.toBN( + allPreMigrationBalances.cSaiUnderlyingRaw + ); + let preMigrationBalances = { + dDaiUnderlyingRaw: dDaiUnderlyingRaw.toString(), + cSaiUnderlyingRaw: cSaiUnderlyingRaw.toString() + }; + + let postDDaiUnderlyingRaw = dDaiUnderlyingRaw.add(cSaiUnderlyingRaw); + let postMigrationBalances = { + dDaiUnderlyingRaw: postDDaiUnderlyingRaw.toString(), + cSaiUnderlyingRaw: ZERO.toString() + }; + + await tester.withBalanceCheck( + UserSmartWalletV7.options.address, + preMigrationBalances, + postMigrationBalances, + tester.runTest, + [ + "V7 UserSmartWallet relay can trigger cSai to dDai migration", + UserSmartWalletV7, + "migrateCSaiToDDai", + "send", + [], + true, + receipt => { + // TODO: verify logs + }, + tester.originalAddress + ] + ); + + // await tester.runTest( + // "V7 UserSmartWallet relay can trigger cSai to dDai migration", + // UserSmartWalletV7, + // "migrateCSaiToDDai", + // "send", + // [], + // true, + // receipt => { + // // TODO: verify logs + // }, + // tester.originalAddress + // ); + await tester.runTest( "V7 UserSmartWallet relay can trigger cSai to dDai migration again (no-op)", UserSmartWalletV7, @@ -6574,23 +6626,23 @@ async function test(testingContext) { [UserSmartWalletV7.options.address, web3.utils.toWei("1", "mwei")] ); - let allPreMigrationBalances = await tester.getBalances( + allPreMigrationBalances = await tester.getBalances( UserSmartWalletV7.options.address ); - const dDaiUnderlyingRaw = web3.utils.toBN( + dDaiUnderlyingRaw = web3.utils.toBN( allPreMigrationBalances.dDaiUnderlyingRaw ); - const cDaiUnderlyingRaw = web3.utils.toBN( + let cDaiUnderlyingRaw = web3.utils.toBN( allPreMigrationBalances.cDaiUnderlyingRaw ); - let preMigrationBalances = { + preMigrationBalances = { dDaiUnderlyingRaw: dDaiUnderlyingRaw.toString(), cDaiUnderlyingRaw: cDaiUnderlyingRaw.toString() }; - const postDDaiUnderlyingRaw = dDaiUnderlyingRaw.add(cDaiUnderlyingRaw); - let postMigrationBalances = { + postDDaiUnderlyingRaw = dDaiUnderlyingRaw.add(cDaiUnderlyingRaw); + postMigrationBalances = { dDaiUnderlyingRaw: postDDaiUnderlyingRaw.toString(), cDaiUnderlyingRaw: ZERO.toString() }; @@ -6614,6 +6666,27 @@ async function test(testingContext) { ] ); + await tester.runTest( + "Smal amount of cDai can be sent to V7 UserSmartWallet", + tester.CDAI, + "transfer", + "send", + [UserSmartWalletV7.options.address, web3.utils.toWei("1", "wei")] + ); + + await tester.runTest( + "V7 UserSmartWallet cDai to dDai migration fails with a small amount of cDai", + UserSmartWalletV7, + "migrateCDaiToDDai", + "send", + [], + false, + receipt => { + // TODO: verify logs + }, + tester.originalAddress + ); + await tester.runTest( "cDai can be sent to V7 UserSmartWallet again", tester.CDAI, diff --git a/scripts/test/testHelpers.js b/scripts/test/testHelpers.js index e1ea545..acb0eef 100644 --- a/scripts/test/testHelpers.js +++ b/scripts/test/testHelpers.js @@ -819,7 +819,6 @@ class Tester { // Get the final balances. const finalBalances = await this.getBalances(account); - const fiinalBalancesSet = new Set(Object.keys(finalBalances)); for (const balance of balanceChecks) { assert.strictEqual(finalBalances[balance], final[balance]); From 26aaf6b8cbb134c9ada5cc46df9d6ed6c6ce6e77 Mon Sep 17 00:00:00 2001 From: Carlos Flores Date: Tue, 11 Feb 2020 11:08:23 -0800 Subject: [PATCH 2/2] typo --- scripts/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test/test.js b/scripts/test/test.js index 6d03178..e51c687 100644 --- a/scripts/test/test.js +++ b/scripts/test/test.js @@ -6667,7 +6667,7 @@ async function test(testingContext) { ); await tester.runTest( - "Smal amount of cDai can be sent to V7 UserSmartWallet", + "Small amount of cDai can be sent to V7 UserSmartWallet", tester.CDAI, "transfer", "send",