Update so cli.js test works

- Use websnark version that supports trusted setup
 - Fix cli.js
This commit is contained in:
Brian Li 2021-04-25 23:24:08 -07:00
parent d946cf0808
commit 3af3379688
4 changed files with 11 additions and 11 deletions

14
cli.js
View File

@ -51,7 +51,7 @@ async function printERC20Balance({address, name, tokenAddress}, currency) {
await printCELOBalance({address, name})
return
}
const erc20ContractJson = require('./build/contracts/ERC20Mock.json')
const erc20ContractJson = require('./client/contracts/ERC20Mock.json')
console.log(`${name} Token Balance is`, await erc20.methods.balanceOf(address).call())
}
@ -97,7 +97,7 @@ async function deposit({currency, amount}) {
}
console.log('Submitting deposit transaction')
const depositTx = await tornado.methods.deposit(toHex(deposit.commitment))
const depositTx = await tornado.methods.deposit(toHex(deposit.commitment), [])
const depositTxRes = await kit.sendTransactionObject(depositTx, {from: senderAccount, gas: 2e6})
console.log("Deposit txn:", await depositTxRes.getHash())
await printERC20Balance({address: tornado._address, name: 'Tornado'}, currency)
@ -479,7 +479,7 @@ async function init({rpc, noteNetId, currency = 'dai', amount = '100'}) {
// Initialize using injected web3 (Metamask)
// To assemble web version run `npm run browserify`
web3 = new Web3(window.web3.currentProvider, null, {transactionConfirmationBlocks: 1})
contractJson = await (await fetch('build/contracts/ETHTornado.json')).json()
contractJson = await (await fetch('client/contracts/ERC20Tornado.json')).json()
circuit = await (await fetch('build/circuits/withdraw.json')).json()
proving_key = await (await fetch('build/circuits/withdraw_proving_key.bin')).arrayBuffer()
MERKLE_TREE_HEIGHT = 20
@ -490,7 +490,7 @@ async function init({rpc, noteNetId, currency = 'dai', amount = '100'}) {
// Initialize from local node
web3 = new Web3(rpc)
kit = ContractKit.newKitFromWeb3(web3)
contractJson = require('./build/contracts/ETHTornado.json')
contractJson = require('./client/contracts/ERC20Tornado.json')
circuit = require('./build/circuits/withdraw.json')
proving_key = fs.readFileSync('build/circuits/withdraw_proving_key.bin').buffer
MERKLE_TREE_HEIGHT = process.env.MERKLE_TREE_HEIGHT || 20
@ -505,8 +505,8 @@ async function init({rpc, noteNetId, currency = 'dai', amount = '100'}) {
} else {
console.log('Warning! PRIVATE_KEY not found. Please provide PRIVATE_KEY in .env file if you deposit')
}
erc20ContractJson = require('./build/contracts/ERC20Mock.json')
erc20tornadoJson = require('./build/contracts/ERC20Tornado.json')
erc20ContractJson = require('./client/contracts/ERC20Mock.json')
erc20tornadoJson = require('./client/contracts/ERC20Tornado.json')
}
// groth16 initialises a lot of Promises that will never be resolved, that's why we need to use process.exit to terminate the CLI
groth16 = await buildGroth16()
@ -614,7 +614,7 @@ async function main() {
.description('Perform an automated test. It deposits and withdraws one ETH and one ERC20 note. Uses ganache.')
.action(async () => {
console.log('Start performing ETH deposit-withdraw test')
let currency = 'celo'
let currency = 'erc20mock'
let amount = '0.1'
await init({rpc: program.rpc, currency, amount})
let noteString = await deposit({currency, amount})

View File

@ -16,7 +16,7 @@ module.exports = function (deployer, network, accounts) {
const hasherInstance = await hasherContract.deployed()
await ERC20Tornado.link(hasherContract, hasherInstance.address)
let token = ERC20_TOKEN
if (token === '') {
if (token === '' || network === 'development') {
const tokenInstance = await deployer.deploy(ERC20Mock)
token = tokenInstance.address
}

4
package-lock.json generated
View File

@ -18523,8 +18523,8 @@
"optional": true
},
"websnark": {
"version": "git+https://github.com/tornadocash/websnark.git#2041cfa5fa0b71cd5cca9022a4eeea4afe28c9f7",
"from": "git+https://github.com/tornadocash/websnark.git#2041cfa5fa0b71cd5cca9022a4eeea4afe28c9f7",
"version": "git+https://github.com/tornadocash/websnark.git#4c0af6a8b65aabea3c09f377f63c44e7a58afa6d",
"from": "git+https://github.com/tornadocash/websnark.git#4c0af6a8b65aabea3c09f377f63c44e7a58afa6d",
"requires": {
"big-integer": "^1.6.42"
}

View File

@ -49,7 +49,7 @@
"truffle": "^5.0.44",
"truffle-flattener": "^1.4.2",
"web3": "^1.2.11",
"websnark": "git+https://github.com/tornadocash/websnark.git#2041cfa5fa0b71cd5cca9022a4eeea4afe28c9f7"
"websnark": "git+https://github.com/tornadocash/websnark.git#4c0af6a8b65aabea3c09f377f63c44e7a58afa6d"
},
"devDependencies": {
"@celo/contractkit": "^1.0.2"