Hi @leckylao,
Currently the repository https://github.com/leckylao/GnosisSafeModule doesn’t work for truffle test
.
$ npx truffle test
Could not find suitable configuration file.
Truffle v5.1.24 (core: 5.1.24)
Node v10.19.0
I initialized using truffle to create the config file but didn’t overwrite the contracts or tests.
$ npx truffle init
But as you don’t have a Migrations.sol
I had to delete the migrations script that truffle init
creates.
I had to fix the artifact names (you don’t need the .sol
e.g. ./GnosisSafe.sol
can be GnosisSafe
)
const { accounts, contract } = require('@openzeppelin/test-environment');
const [ owner ] = accounts;
describe('GnosisSafeModule', function () {
const Web3 = require('web3');
const web3 = new Web3();
const utils = require('@gnosis.pm/safe-contracts/test/utils/general');
const GnosisSafe = contract.fromArtifact("GnosisSafe");
const ProxyFactory = contract.fromArtifact("GnosisSafeProxyFactory");
const GnosisSafeModule = contract.fromArtifact("GnosisSafeModule");
});
I had to install @truffle/debug-utils
$ npm i @truffle/debug-utils
I was then able to run npx truffle test
OpenZeppelin Test Environment
Truffle provides web3
OpenZeppelin Test environment provides web3
but you need to obtain it.
This means that the current utils/general.js
works as is with Truffle but requires the addition of const { web3 } = require('@openzeppelin/test-environment');
There may also be other things which would need to be migrated to work on OpenZeppelin Test Environment. It depends what you use from this helper.
I created a local copy of utils/general.js
with the only difference being the addition of the following line:
const { web3 } = require('@openzeppelin/test-environment');
I then modified testGnosisSafeModule.js
as follows to:
- add getting
web3
from @openzeppelin/test-environment
.
- change to use the local copy of `./utils/general.js’
- fixed artifact names (you don’t need the
.sol
e.g. ./GnosisSafe.sol
can be GnosisSafe
)
testGnosisSafeModule.js
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const [ owner ] = accounts;
describe('GnosisSafeModule', function () {
//const Web3 = require('web3'); provided by @openzeppelin/test-environment
//const web3 = new Web3();
const utils = require('./utils/general'); // use local copy to get web3 from test-environment
const GnosisSafe = contract.fromArtifact("GnosisSafe");
const ProxyFactory = contract.fromArtifact("GnosisSafeProxyFactory");
const GnosisSafeModule = contract.fromArtifact("GnosisSafeModule");
});
$ npm run test
> test-gnosis@0.1.0 test /home/abcoathup/projects/forum/GnosisSafeModule
> mocha --exit --recursive test
0 passing (1ms)