twinstake / permissioned-delegation-matic

0 stars 0 forks source link

`ValidatorShare` test converted from js to ts #5

Open eliotstock opened 1 year ago

eliotstock commented 1 year ago

I see you've taken the test in the upstream repo for ValidatorShare and converted it to Typescript. This makes it very difficult to diff the tests against the ones in the upstream repo.

In general we should aiming to minimise the diff between this repo and upstream to only what we need to add the whitelist. Anything more than this is cope creep and makes reviewing/auditing this code much harder.

rac-sri commented 1 year ago

yes, the reason is the libraries used in the upstream use require. And Hardhat wasn't ok with that and was asking for module types if I remember correctly. Also, due to the difference between the packages used ( since some are based on an old version ), adding type:module to package.json didn't work either. Switching to ts worked smoothly at the end and resorted to ts due to the limited delivery timeline.

eliotstock commented 1 year ago

But there is no hardhat at all in upstream. It uses truffle, correct?

Why did you move to hardhat?

It seems like you have not tried to create a minimal diff against upstream.

eliotstock commented 1 year ago

Was it because you got the errors below on npm install when using the Node version in upstream?

If so, did you try to get python 2 working with it?

I was able to get this to work using pyenv, at least as far as running the tests.

pyenv install 2.7.15
pyenv local 2.7.15
npm install
npm run template:process -- --bor-chain-id 137
npm run truffle:compile
npm run testrpc &
npm run bor:simulate &
npm run truffle:migrate
npm test
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /home/e/.pyenv/shims/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack pyenv: python: command not found
gyp ERR! stack 
gyp ERR! stack The `python' command exists in these Python versions:
gyp ERR! stack   3.9.15
gyp ERR! stack   3.9.15/envs/keyboard
gyp ERR! stack   3.9.15/envs/ts
gyp ERR! stack   3.9.15/envs/venv2
gyp ERR! stack   keyboard
gyp ERR! stack   ts
gyp ERR! stack   venv2
gyp ERR! stack 
gyp ERR! stack Note: See 'pyenv help global' for tips on allowing both
gyp ERR! stack       python2 and python3 to be found.
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)
gyp ERR! System Linux 5.19.0-41-generic
gyp ERR! command "/home/e/.nvm/versions/node/v11.1.0/bin/node" "/home/e/.nvm/versions/node/v11.1.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/e/r/ts/matic-contracts/node_modules/ethereumjs-util/node_modules/keccak
gyp ERR! node -v v11.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/e/.npm/_logs/2023-05-11T02_17_31_481Z-debug.log