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

fix offchain connection and tests #642

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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