Skip to content

Commit

Permalink
Merge pull request #642 from EYBlockchain/westlad/test-fix
Browse files Browse the repository at this point in the history
fix offchain connection and tests
  • Loading branch information
Westlad authored May 10, 2022
2 parents a845623 + 3d4d131 commit f8520ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
20 changes: 9 additions & 11 deletions nightfall-client/src/services/transfer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,18 @@ async function transfer(transferParams) {
// dig up connection peers
const peerList = await getProposersUrl(NEXT_N_PROPOSERS);
logger.debug(`Peer List: ${JSON.stringify(peerList, null, 2)}`);
Object.keys(peerList).forEach(async address => {
logger.debug(
`offchain transaction - calling ${peerList[address]}/proposer/offchain-transaction`,
);
await axios
.post(
await Promise.all(
Object.keys(peerList).map(async address => {
logger.debug(
`offchain transaction - calling ${peerList[address]}/proposer/offchain-transaction`,
);
return axios.post(
`${peerList[address]}/proposer/offchain-transaction`,
{ transaction: optimisticTransferTransaction },
{ timeout: 3600000 },
)
.catch(err => {
throw new Error(err);
});
});
);
}),
);
// we only want to store our own commitments so filter those that don't
// have our public key
newCommitments
Expand Down
21 changes: 10 additions & 11 deletions nightfall-client/src/services/withdraw.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,19 @@ async function withdraw(withdrawParams) {
try {
if (offchain) {
const peerList = await getProposersUrl(NEXT_N_PROPOSERS);
Object.keys(peerList).forEach(async address => {
logger.debug(
`offchain transaction - calling ${peerList[address]}/proposer/offchain-transaction`,
);
await axios
.post(
logger.debug(`Peer List: ${JSON.stringify(peerList, null, 2)}`);
await Promise.all(
Object.keys(peerList).map(async address => {
logger.debug(
`offchain transaction - calling ${peerList[address]}/proposer/offchain-transaction`,
);
return axios.post(
`${peerList[address]}/proposer/offchain-transaction`,
{ transaction: optimisticWithdrawTransaction },
{ timeout: 3600000 },
)
.catch(err => {
throw new Error(err);
});
});
);
}),
);
// on successful computation of the transaction mark the old commitments as nullified
await markNullified(oldCommitment, optimisticWithdrawTransaction);
const th = optimisticWithdrawTransaction.transactionHash;
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/tokens/erc20.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ const emptyL2 = async nf3Instance => {
describe('ERC20 tests', () => {
before(async () => {
await nf3Proposer.init(mnemonics.proposer);
await nf3Proposer.registerProposer();
// we must set the URL from the point of view of the client container
await nf3Proposer.registerProposer('http://optimist1');

// Proposer listening for incoming events
const newGasBlockEmitter = await nf3Proposer.startProposer();
Expand Down

0 comments on commit f8520ae

Please sign in to comment.