Merge pull request #53 from gnidan/fix-weird-test-error

Fix strange failure to run tests the first time
This commit is contained in:
Roman Storm 2020-06-09 12:42:45 -07:00 committed by GitHub
commit 5c3648cedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 39 deletions

21
compileHasher.js Normal file
View File

@ -0,0 +1,21 @@
// Generates Hasher artifact at compile-time using Truffle's external compiler
// mechanism
const path = require('path')
const fs = require('fs')
const genContract = require('circomlib/src/mimcsponge_gencontract.js')
// where Truffle will expect to find the results of the external compiler
// command
const outputPath = path.join(__dirname, 'build', 'Hasher.json')
function main () {
const contract = {
contractName: 'Hasher',
abi: genContract.abi,
bytecode: genContract.createCode('mimcsponge', 220)
}
fs.writeFileSync(outputPath, JSON.stringify(contract))
}
main()

View File

@ -1,21 +1,6 @@
/* global artifacts */
const path = require('path')
const Hasher = artifacts.require('Hasher')
const genContract = require('circomlib/src/mimcsponge_gencontract.js')
const Artifactor = require('@truffle/artifactor')
module.exports = function(deployer) {
return deployer.then( async () => {
const contractsDir = path.join(__dirname, '..', 'build/contracts')
let artifactor = new Artifactor(contractsDir)
let contractName = 'Hasher'
await artifactor.save({
contractName,
abi: genContract.abi,
unlinked_binary: genContract.createCode('mimcsponge', 220),
}).then(async () => {
const hasherContract = artifacts.require(contractName)
await deployer.deploy(hasherContract)
})
})
module.exports = async function(deployer) {
await deployer.deploy(Hasher)
}

20
package-lock.json generated
View File

@ -151,16 +151,6 @@
"defer-to-connect": "^1.0.1"
}
},
"@truffle/artifactor": {
"version": "4.0.38",
"resolved": "https://registry.npmjs.org/@truffle/artifactor/-/artifactor-4.0.38.tgz",
"integrity": "sha512-blkKmw0CdiJ4V2Xz9s8aHhcHHE3nr5jgQrgyI2fQhW3gfWLUUl9TQ+TLgNBDd90+aUqhPyTQRzy8lH1Z4xxmmg==",
"requires": {
"@truffle/contract-schema": "^3.0.18",
"fs-extra": "6.0.1",
"lodash": "^4.17.13"
}
},
"@truffle/blockchain-utils": {
"version": "0.0.14",
"resolved": "https://registry.npmjs.org/@truffle/blockchain-utils/-/blockchain-utils-0.0.14.tgz",
@ -3683,16 +3673,6 @@
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
},
"fs-extra": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs-minipass": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz",

View File

@ -28,7 +28,6 @@
"license": "ISC",
"dependencies": {
"@openzeppelin/contracts": "^2.4.0",
"@truffle/artifactor": "^4.0.38",
"@truffle/contract": "^4.0.39",
"@truffle/hdwallet-provider": "^1.0.24",
"axios": "^0.19.0",

View File

@ -95,6 +95,12 @@ module.exports = {
},
// evmVersion: "byzantium"
}
},
external: {
command: 'node ./compileHasher.js',
targets: [{
path: './build/Hasher.json'
}]
}
}
}