Skip to content

Commit

Permalink
fix: ping pong test
Browse files Browse the repository at this point in the history
  • Loading branch information
Westlad committed Jun 16, 2022
1 parent ee3add1 commit 958e3c9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions cli/lib/nf3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ class Nf3 {
!!this.ethereumSigningKey,
);
} catch (err) {
logger.error(`Approve transaction failed`);
throw new Error(err);
}
if (txDataToSign) {
Expand All @@ -406,6 +407,7 @@ class Nf3 {
);
resolve(receipt);
} catch (err) {
logger.error('Deposit transaction failed');
reject(err);
}
});
Expand Down
2 changes: 1 addition & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ module.exports = {
development: [
{
name: 'ERC20Mock',
address: '0xB5Acbe9a0F1F8B98F3fC04471F7fE5d2c222cB44',
address: '0x470556dE5865D293dCcc0b47644fac7721168065',
amount: '100000000000',
},
{
Expand Down
1 change: 1 addition & 0 deletions nightfall-deployer/migrations/2_deploy_upgradeable.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = async function (deployer) {
const restrictions = await Shield.deployed();
// restrict transfer amounts
for (let token of RESTRICTIONS.tokens[process.env.ETH_NETWORK]) {
if (token.name = 'ERC20Mock') break; // ignore test tokens, they're already handled in the test_tokens migration
console.log(`Max allowed deposit value for ${token.name}: ${(BigInt(token.amount) / BigInt(4)).toString()}`); // BigInt division returns whole number which is a floor. Not Math.floor() needed
console.log(`Max allowed withdraw value for ${token.name}: ${token.amount}`);
await restrictions.setRestriction(token.address, (BigInt(token.amount) / BigInt(4)).toString(), token.amount);
Expand Down
16 changes: 9 additions & 7 deletions nightfall-deployer/migrations/3_test_tokens_migration.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
const config = require('config');

const {
TEST_OPTIONS: {
restrictions: { erc20default },
addresses,
},
RESTRICTIONS,
} = config;
const { TEST_OPTIONS: { addresses }, RESTRICTIONS } = config;
const { DEPLOY_MOCK_TOKENS = true } = process.env;

const Shield = artifacts.require('Shield.sol');
Expand All @@ -32,6 +26,14 @@ module.exports = function (deployer, _, accounts) {
await ERC20deployed.transfer(addresses.user2, 1000000000000);
await ERC20deployed.transfer(restrictions.address, 1000000000000); // for testing Shield balance withdraw

// set restictions for test ERC20Mock contract (we handle this differently because the address is not fixed)
try {
const erc20MockRestriction = RESTRICTIONS.tokens[process.env.ETH_NETWORK].find(el => el.name === 'ERC20Mock').amount;
await restrictions.setRestriction(ERC20Mock.address, (BigInt(erc20MockRestriction) / BigInt(4)).toString(), erc20MockRestriction);
} catch (err) {
console.warn('Test contract restrictions were not set, and yet you have deployed test contracts');
}

if (!config.ETH_ADDRESS) {
// indicates we're running a wallet test that uses hardcoded addresses
// For e2e tests
Expand Down

0 comments on commit 958e3c9

Please sign in to comment.