Skip to content

Commit

Permalink
Merge pull request #16 from dharma-eng/validation-improvements
Browse files Browse the repository at this point in the history
migrateCSaiToDDai and small cDai mint failure
  • Loading branch information
Carlos Flores authored Feb 11, 2020
2 parents f92ecac + 26aaf6b commit 9906efd
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 15 deletions.
101 changes: 87 additions & 14 deletions scripts/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
};
Expand All @@ -6614,6 +6666,27 @@ async function test(testingContext) {
]
);

await tester.runTest(
"Small 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,
Expand Down
1 change: 0 additions & 1 deletion scripts/test/testHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 9906efd

Please sign in to comment.