Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting tests #490

Merged
merged 27 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
86175e3
fix: step 1
signorecello Jan 27, 2022
27e3384
fix: step 2.1
signorecello Jan 27, 2022
aeead47
fix: step 2.1
signorecello Jan 27, 2022
3de066d
fix: step 2.2
signorecello Jan 27, 2022
4993647
fix: step 2.3
signorecello Jan 28, 2022
d8e8233
fix: step 2.4
signorecello Jan 28, 2022
ea8af30
fix: step 2.3
signorecello Jan 31, 2022
10d1877
fix: fixing conflicts
signorecello Jan 31, 2022
9a1a715
fix: fixing #437 and cleaning up a bit
signorecello Feb 2, 2022
d7de625
fix: adding instant withdrawals and some more stuff
signorecello Feb 3, 2022
7b231b0
fix: adding some stability to the tests, added coverage testing as we…
signorecello Feb 6, 2022
d658646
fix: removing ignored files
signorecello Feb 6, 2022
d2a29c6
fix: all tests working 🎉
signorecello Feb 8, 2022
b36c193
fix: merging gas costs into e2e, attempting to fix github actions
signorecello Feb 9, 2022
d782b83
fix: wip
signorecello Feb 9, 2022
18aed89
fix: merging with master
signorecello Feb 9, 2022
555cf10
fix: wip
signorecello Feb 10, 2022
b90ae14
fix: fixing merge conflicts messing up with 12 confirmations
signorecello Feb 11, 2022
e8b904f
fix: cleaning up 🧹
signorecello Feb 11, 2022
33c1809
fix: cleaning up some more 🧹
signorecello Feb 11, 2022
5dac420
fix: removing wallet tests, as the wallet is deprecated anyway and it…
signorecello Feb 11, 2022
0269992
fix: adding more verbosity to gh tests, adding a missing blockpropose…
signorecello Feb 14, 2022
b9a0675
fix: fixing conflicts
signorecello Feb 14, 2022
a43963a
fix: fixing conflicts with #398 and moving eslint rule to a per-file …
signorecello Feb 14, 2022
6ca1b30
fix: trying to add healthchecks instead of waiting for gh actions 🕓
signorecello Feb 14, 2022
d2e79b7
fix: making changes as suggested in the PR
signorecello Feb 17, 2022
82adde5
fix: fixing conflicts
signorecello Feb 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 2 additions & 37 deletions .github/workflows/check-PRs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
- name: Run integration test
run: |
npm ci
npm test
VERBOSE=true npm run test-e2e-protocol
VERBOSE=true npm run test-e2e-tokens

- name: debug logs - after integration test run
if: always()
Expand All @@ -59,42 +60,6 @@ jobs:
name: ganache-test-logs
path: ./ganache-test.log

wallet-test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '14.17.0'

- name: Start Containers
run: |
docker build --no-cache -t ghcr.io/eyblockchain/local-zokrates -f zokrates.Dockerfile .
docker-compose build
./start-nightfall -wt -s &

- name: wait 2500s for Containers startup and test completion
run: sleep 2500

- name: Retrieve Wallet test logs
run: docker logs $(docker ps -aqf "name=wallet-test") > wallet-test.log; cat wallet-test.log;

- name: debug logs - after container startup
if: always()
run: if [ -z "$(cat wallet-test.log | grep FAILED)" ]; then exit 0; else exit 1; fi

- name: If integration test failed, shutdown the Containers
if: failure()
run: docker-compose -f docker-compose.yml -f docker-compose.ganache.yml -f docker-compose.wallet-test.yml down -v

- name: If integration test failed, upload logs files as artifacts
if: failure()
uses: actions/upload-artifact@master
with:
name: wallet-test-logs
path: ./wallet-test.log


test-gas:
name: check gas for 32 transactions per block
runs-on: ubuntu-20.04
Expand Down
30 changes: 0 additions & 30 deletions .husky/_/husky.sh

This file was deleted.

59 changes: 26 additions & 33 deletions cli/lib/nf3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ class Nf3 {
currentEnvironment;

constructor(
web3WsUrl,
ethereumSigningKey,
environment = {
clientApiUrl: 'http://localhost:8080',
optimistApiUrl: 'http://localhost:8081',
optimistWsUrl: 'ws://localhost:8082',
web3WsUrl: 'ws://localhost:8546',
},
zkpKeys,
) {
this.clientBaseUrl = environment.clientApiUrl;
this.optimistBaseUrl = environment.optimistApiUrl;
this.optimistWsUrl = environment.optimistWsUrl;
this.web3WsUrl = web3WsUrl;
this.web3WsUrl = environment.web3WsUrl;
this.ethereumSigningKey = ethereumSigningKey;
this.zkpKeys = zkpKeys;
this.currentEnvironment = environment;
Expand Down Expand Up @@ -164,6 +164,16 @@ class Nf3 {
return this.subscribeToIncomingViewingKeys();
}

/**
Gets the number of unprocessed transactions on the optimist
@async
*/

async unprocessedTransactionCount() {
ChaitanyaKonda marked this conversation as resolved.
Show resolved Hide resolved
const { result: mempool } = (await axios.get(`${this.optimistBaseUrl}/proposer/mempool`)).data;
return mempool.filter(e => e.mempool).length;
}

/**
Method for signing and submitting an Ethereum transaction to the
blockchain.
Expand All @@ -186,7 +196,7 @@ class Nf3 {
let tx;
await this.nonceMutex.runExclusive(async () => {
// if we don't have a nonce, we must get one from the ethereum client
if (!this.nonce) this.nonce = await this.web3.eth.getTransactionCount(this.ethereumAddress);
this.nonce = await this.web3.eth.getTransactionCount(this.ethereumAddress);
Westlad marked this conversation as resolved.
Show resolved Hide resolved

let gasPrice = 20000000000;
const gas = (await this.web3.eth.getBlock('latest')).gasLimit;
Expand All @@ -210,20 +220,24 @@ class Nf3 {
// rather than waiting until we have a receipt, wait until we have enough confirmation blocks
// then return the receipt.
// TODO does this still work if there is a chain reorg or do we have to handle that?
return new Promise(resolve => {
console.log(`Confirming transaction ${signed.transactionHash}`);
return new Promise((resolve, reject) => {
if (process.env.VERBOSE) console.log(`Confirming transaction ${signed.transactionHash}`);
this.notConfirmed++;
this.web3.eth
.sendSignedTransaction(signed.rawTransaction)
.on('confirmation', (number, receipt) => {
if (number === 12) {
this.notConfirmed--;
console.log(
`Transaction ${receipt.transactionHash} has been confirmed ${number} times.`,
`Number of unconfirmed transactions is ${this.notConfirmed}`,
);
if (process.env.VERBOSE)
console.log(
`Transaction ${receipt.transactionHash} has been confirmed ${number} times.`,
`Number of unconfirmed transactions is ${this.notConfirmed}`,
);
resolve(receipt);
}
})
.on('error', err => {
reject(err);
});
});
}
Expand Down Expand Up @@ -270,7 +284,7 @@ class Nf3 {
*/
async getContractAddress(contractName) {
const res = await axios.get(`${this.clientBaseUrl}/contract-address/${contractName}`);
return res.data.address;
return res.data.address.toLowerCase();
}

/**
Expand Down Expand Up @@ -424,7 +438,7 @@ class Nf3 {
});
this.latestWithdrawHash = res.data.transaction.transactionHash;
if (!offchain) {
const receiptPromise = this.submitTransaction(
const receiptPromise = await this.submitTransaction(
Westlad marked this conversation as resolved.
Show resolved Hide resolved
res.data.txDataToSign,
this.shieldContractAddress,
fee,
Expand Down Expand Up @@ -767,33 +781,12 @@ class Nf3 {
@method
@async
@param {Array} ercList - list of erc contract addresses to filter.
@param {Boolean} filterByCompressedPkd - flag to indicate if request is filtered
ones compressed pkd
@returns {Promise} This promise resolves into an object whose properties are the
addresses of the ERC contracts of the tokens held by this account in Layer 2. The
value of each propery is the number of tokens originating from that contract.
*/
async getLayer2Balances(ercList, filterByCompressedPkd) {
async getLayer2Balances({ ercList } = {}) {
const res = await axios.get(`${this.clientBaseUrl}/commitment/balance`, {
params: {
compressedPkd: filterByCompressedPkd === true ? this.zkpKeys.compressedPkd : null,
ercList,
},
});
return res.data.balance;
}

/**
Returns the balance details of tokens held in layer 2
@method
@async
@param {Array} ercList - list of erc contract addresses to filter.
@returns {Promise} This promise resolves into an object whose properties are the
addresses of the ERC contracts of the tokens held by this account in Layer 2. The
value of each propery is the number of tokens originating from that contract.
*/
async getLayer2BalancesDetails(ercList) {
const res = await axios.get(`${this.clientBaseUrl}/commitment/balance-details`, {
params: {
compressedPkd: this.zkpKeys.compressedPkd,
ercList,
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
OPTIMIST_PORT: 80
USE_STUBS: 'false' # make sure this flag is the same as in deployer service
RETRIES: 80
command: ['npm', 'run', 'dev']
command: [ 'npm', 'run', 'dev' ]

client2:
build:
Expand Down Expand Up @@ -89,7 +89,7 @@ services:
OPTIMIST_HOST: optimist2
OPTIMIST_PORT: 80
USE_STUBS: 'false' # make sure this flag is the same as in deployer service
command: ['npm', 'run', 'dev']
command: [ 'npm', 'run', 'dev' ]

worker:
# image: 3800decac71d
Expand All @@ -115,7 +115,6 @@ services:
- nightfall_network
environment:
LOG_LEVEL: info

# Temporary container to deploy contracts and circuits and populate volumes
deployer:
#image: docker.pkg.github.com/eyblockchain/nightfall-deployer/nightfall_deployer:1.1.0
Expand Down Expand Up @@ -211,7 +210,7 @@ services:
LOG_LEVEL: debug
IS_CHALLENGER: 'true'
TRANSACTIONS_PER_BLOCK: ${TRANSACTIONS_PER_BLOCK:-2}
command: ['npm', 'run', 'dev']
command: [ 'npm', 'run', 'dev' ]

optimist2:
build:
Expand Down Expand Up @@ -246,7 +245,7 @@ services:
LOG_LEVEL: error
IS_CHALLENGER: 'true'
TRANSACTIONS_PER_BLOCK: ${TRANSACTIONS_PER_BLOCK:-2}
command: ['npm', 'run', 'dev']
command: [ 'npm', 'run', 'dev' ]

volumes:
mongodb1:
Expand Down
13 changes: 0 additions & 13 deletions nightfall-client/src/routes/commitment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
getWalletBalanceUnfiltered,
getWalletCommitments,
getWithdrawCommitments,
getWalletBalanceDetails,
getWalletPendingDepositBalance,
getWalletPendingSpentBalance,
} from '../services/commitment-storage.mjs';
Expand Down Expand Up @@ -46,18 +45,6 @@ router.get('/balance', async (req, res, next) => {
}
});

router.get('/balance-details', async (req, res, next) => {
logger.debug('commitment/balance details endpoint received GET');
try {
const { compressedPkd, ercList } = req.query;
const balance = await getWalletBalanceDetails(compressedPkd, ercList);
res.json({ balance });
} catch (err) {
logger.error(err);
next(err);
}
});

router.get('/pending-deposit', async (req, res, next) => {
logger.debug('commitment/pending-deposit endpoint received GET');
try {
Expand Down
Loading