Skip to content

Commit

Permalink
build: resolve all floating promise warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Apr 24, 2023
1 parent 088b0ab commit cd3a199
Show file tree
Hide file tree
Showing 79 changed files with 227 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
extends: ['@agoric'],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'@typescript-eslint/no-floating-promises': lintTypes ? 'warn' : 'off',
'@typescript-eslint/no-floating-promises': lintTypes ? 'error' : 'off',
// so that floating-promises can be explicitly permitted with void operator
'no-void': ['error', { allowAsStatement: true }],

Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/test/unitTests/test-inputValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ test('makeIssuerKit bad optShutdownWithFailure', async t => {
test('brand.isMyIssuer bad issuer', async t => {
const { brand } = makeIssuerKit('myTokens');
// @ts-expect-error Intentional wrong type for testing
t.throwsAsync(() => brand.isMyIssuer('not an issuer'), {
await t.throwsAsync(() => brand.isMyIssuer('not an issuer'), {
message:
'In "isMyIssuer" method of (myTokens brand): arg 0: string "not an issuer" - Must be a remotable (Issuer)',
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/test/unitTests/test-issuerObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test('issuer.makeEmptyPurse', async t => {
const performWithdrawal = () => purse.withdraw(fungible837);

const checkWithdrawal = async newPayment => {
issuer.getAmountOf(newPayment).then(amount => {
await issuer.getAmountOf(newPayment).then(amount => {
t.assert(
AmountMath.isEqual(amount, fungible837),
`the withdrawn payment has the right balance`,
Expand Down
10 changes: 6 additions & 4 deletions packages/agoric-cli/src/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ export default async function deployMain(progname, rawArgs, powers, opts) {
publishBundleHttp,
});

const retryWebsocket = async () => {
const accessToken = await getAccessToken(`${wsurl.hostname}:${myPort}`);

const retryWebsocket = accessToken => {
// For a WebSocket we need to put the token in the query string.
const wsWebkey = `${wsurl}?accessToken=${encodeURIComponent(accessToken)}`;

Expand Down Expand Up @@ -509,7 +507,11 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
exit.reject(e);
});
};

const accessToken = await getAccessToken(`${wsurl.hostname}:${myPort}`);

// Start the retry process.
retryWebsocket();
retryWebsocket(accessToken);

return exit.promise;
}
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,11 @@ export default async function main(progname, args, { env, homedir, agcc }) {
},
);

exportData.exporter.onDone().catch(() => {
exportData.exporter.onDone().catch(async () => {
if (exportData === stateSyncExport) {
stateSyncExport = undefined;
}
exportData.cleanup();
await exportData.cleanup();
});

return exportData.exporter.onStarted().catch(err => {
Expand Down
6 changes: 3 additions & 3 deletions packages/cosmic-swingset/src/export-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ export const spawnSwingStoreExport = (
cp.on('error', kits.done.reject).on('exit', onExit).on('message', onMessage);

kits.done.promise
.catch(err => {
kits.started.reject(err);
})
.then(() => {
cp.off('error', kits.done.reject)
.off('exit', onExit)
.off('message', onMessage);
})
.catch(err => {
kits.started.reject(err);
});

if (cp.exitCode != null) {
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/src/binaryVoteCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const makeBinaryVoteCounter = (
outcome: 'fail',
reason: 'No quorum',
};
E(publisher).publish(voteOutcome);
void E(publisher).publish(voteOutcome);
return;
}

Expand All @@ -122,7 +122,7 @@ const makeBinaryVoteCounter = (
}

// XXX if we should distinguish ties, publish should be called in if above
E.when(outcomePromise.promise, position => {
void E.when(outcomePromise.promise, position => {
/** @type {OutcomeRecord} */
const voteOutcome = {
question: details.questionHandle,
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/contractGovernance/paramManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const makeParamManagerBuilder = (publisherKit, zoe) => {
const build = () => {
// XXX let params be finished async. A concession to upgradability
// UNTIL https://github.com/Agoric/agoric-sdk/issues/4343
E.when(finishBuilding(), () => publish());
void E.when(finishBuilding(), () => publish());

// CRUCIAL: Contracts that call buildParamManager should only export the
// resulting paramManager to their creatorFacet, where it will be picked up by
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/src/multiCandidateVoteCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const makeMultiCandidateVoteCounter = (
outcome: 'fail',
reason: 'No quorum',
};
E(publisher).publish(voteOutcome);
void E(publisher).publish(voteOutcome);
return;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ const makeMultiCandidateVoteCounter = (
outcomePromise.resolve(untiedPositions.concat(tieWinners));
}

E.when(outcomePromise.promise, winPositions => {
void E.when(outcomePromise.promise, winPositions => {
/** @type { MultiOutcomeRecord } */
const voteOutcome = {
question: details.questionHandle,
Expand Down
8 changes: 4 additions & 4 deletions packages/governance/test/unitTests/test-binaryballotCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ test('binary tied', async t => {
const bobSeat = makeHandle('Voter');

const positions = aliceTemplate.getDetails().positions;
E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
await E(creatorFacet).submitVote(bobSeat, [positions[1]]);
closeFacet.closeVoting();
const outcome = await E(publicFacet).getOutcome();
Expand Down Expand Up @@ -297,7 +297,7 @@ test('binary contested', async t => {
const positions = template.getDetails().positions;
t.deepEqual(positions.length, 2);

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
await E(creatorFacet).submitVote(bobSeat, [positions[1]], 47n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -337,8 +337,8 @@ test('binary revote', async t => {
const positions = template.getDetails().positions;
t.deepEqual(positions.length, 2);

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
E(creatorFacet).submitVote(bobSeat, [positions[1]], 47n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
void E(creatorFacet).submitVote(bobSeat, [positions[1]], 47n);
await E(creatorFacet).submitVote(bobSeat, [positions[1]], 15n);
closeFacet.closeVoting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ test('multi candidate contested', async t => {
const positions = template.getDetails().positions;
t.deepEqual(positions.length, 5);

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 2n);
E(creatorFacet).submitVote(bobSeat, [positions[2]], 15n);
E(creatorFacet).submitVote(tedSeat, [positions[1]], 27n);
E(creatorFacet).submitVote(carolSeat, [positions[3]], 17n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 2n);
void E(creatorFacet).submitVote(bobSeat, [positions[2]], 15n);
void E(creatorFacet).submitVote(tedSeat, [positions[1]], 27n);
void E(creatorFacet).submitVote(carolSeat, [positions[3]], 17n);
await E(creatorFacet).submitVote(jackSeat, [positions[4]], 14n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -121,12 +121,12 @@ test('multi candidate tie outcome', async t => {
const positions = template.getDetails().positions;
t.deepEqual(positions.length, 7);

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 3n);
E(creatorFacet).submitVote(bobSeat, [positions[2]], 5n);
E(creatorFacet).submitVote(tedSeat, [positions[1]], 5n);
E(creatorFacet).submitVote(carolSeat, [positions[3]], 8n);
E(creatorFacet).submitVote(johnSeat, [positions[5]], 5n);
E(creatorFacet).submitVote(charlieSeat, [positions[6]], 5n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 3n);
void E(creatorFacet).submitVote(bobSeat, [positions[2]], 5n);
void E(creatorFacet).submitVote(tedSeat, [positions[1]], 5n);
void E(creatorFacet).submitVote(carolSeat, [positions[3]], 8n);
void E(creatorFacet).submitVote(johnSeat, [positions[5]], 5n);
void E(creatorFacet).submitVote(charlieSeat, [positions[6]], 5n);
await E(creatorFacet).submitVote(jackSeat, [positions[4]], 5n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -178,10 +178,10 @@ test('multi candidate tie outcome case #2', async t => {
const positions = template.getDetails().positions;
t.deepEqual(positions.length, 7);

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 3n);
E(creatorFacet).submitVote(bobSeat, [positions[2]], 5n);
E(creatorFacet).submitVote(tedSeat, [positions[1]], 5n);
E(creatorFacet).submitVote(carolSeat, [positions[3]], 7n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 3n);
void E(creatorFacet).submitVote(bobSeat, [positions[2]], 5n);
void E(creatorFacet).submitVote(tedSeat, [positions[1]], 5n);
void E(creatorFacet).submitVote(carolSeat, [positions[3]], 7n);
await E(creatorFacet).submitVote(johnSeat, [positions[5]], 8n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -265,8 +265,8 @@ test('multi candidate revote', async t => {

const positions = template.getDetails().positions;

E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
E(creatorFacet).submitVote(bobSeat, [positions[1]], 15n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]], 23n);
void E(creatorFacet).submitVote(bobSeat, [positions[1]], 15n);
await E(creatorFacet).submitVote(bobSeat, [positions[2]], 47n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -340,7 +340,7 @@ test('multi candidate no quorum', async t => {
t.deepEqual(positions.length, 3);
t.deepEqual(positions[0], FISH);

E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
await E(creatorFacet).submitVote(bobSeat, [positions[1]]);
closeFacet.closeVoting();

Expand Down Expand Up @@ -385,7 +385,7 @@ test('multi candidate specify multiple chocies', async t => {
t.deepEqual(positions.length, 3);
t.deepEqual(positions[0], FISH);

E(creatorFacet).submitVote(aliceSeat, [
void E(creatorFacet).submitVote(aliceSeat, [
positions[0],
positions[1],
positions[2],
Expand Down Expand Up @@ -432,7 +432,7 @@ test('multi candidate specify multiple chocies with varying share weights', asyn
t.deepEqual(positions.length, 3);
t.deepEqual(positions[0], FISH);

E(creatorFacet).submitVote(aliceSeat, [positions[0], positions[1]], 3n);
void E(creatorFacet).submitVote(aliceSeat, [positions[0], positions[1]], 3n);
await E(creatorFacet).submitVote(bobSeat, [positions[1], positions[2]], 4n);
closeFacet.closeVoting();

Expand Down Expand Up @@ -475,8 +475,8 @@ test('multi candidate winners less than max winners', async t => {
const positions = aliceTemplate.getDetails().positions;
t.deepEqual(positions.length, 6);

E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
E(creatorFacet).submitVote(tedSeat, [positions[3]]);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
void E(creatorFacet).submitVote(tedSeat, [positions[3]]);
await E(creatorFacet).submitVote(bobSeat, [positions[5]]);
closeFacet.closeVoting();

Expand Down Expand Up @@ -519,8 +519,8 @@ test('multi candidate single winner', async t => {
const positions = aliceTemplate.getDetails().positions;
t.deepEqual(positions.length, 4);

E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
E(creatorFacet).submitVote(tedSeat, [positions[2]]);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
void E(creatorFacet).submitVote(tedSeat, [positions[2]]);
await E(creatorFacet).submitVote(bobSeat, [positions[2]]);
closeFacet.closeVoting();

Expand Down Expand Up @@ -563,7 +563,7 @@ test('multi candidate single winner tie outcome', async t => {
const positions = aliceTemplate.getDetails().positions;
t.deepEqual(positions.length, 4);

E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
void E(creatorFacet).submitVote(aliceSeat, [positions[0]]);
await E(creatorFacet).submitVote(bobSeat, [positions[1]]);
closeFacet.closeVoting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ test('change a param', async t => {
await E(publicFacet).getSubscription(),
);
const update1 = await notifier.getUpdateSince();
publicFacet.getGovernedParams();
void publicFacet.getGovernedParams();
// This value isn't available synchronously and we don't have access here to the param manager to await its finish
// XXX UNTIL https://github.com/Agoric/agoric-sdk/issues/4343
// t.is(
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/auction/auctionBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
collateralAvailable,
currentPriceLevel: state.curAuctionPrice,
});
state.bookDataKit.recorder.write(bookData);
void state.bookDataKit.recorder.write(bookData);
},
},
self: {
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/auction/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const makeScheduler = async (
now,
),
});
scheduleRecorder.write(sched);
void scheduleRecorder.write(sched);
};

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ export const prepareVaultManagerKit = (
oldCollateral,
);
// debt accounting managed through minting and burning
facets.helper.updateMetrics();
void facets.helper.updateMetrics();
}
},
},
Expand Down Expand Up @@ -1100,7 +1100,7 @@ export const prepareVaultManagerKit = (
);

helper.markLiquidating(totalDebt, totalCollateral);
helper.updateMetrics();
void helper.updateMetrics();

const { userSeatPromise, deposited } = await E.when(
E(auctionPF).getDepositInvitation(),
Expand All @@ -1122,7 +1122,7 @@ export const prepareVaultManagerKit = (
const [proceeds] = await Promise.all([deposited, userSeatPromise]);

trace(`LiqV after long wait`, proceeds);
helper.distributeProceeds(
void helper.distributeProceeds(
proceeds,
totalDebt,
storedCollateralQuote,
Expand All @@ -1145,7 +1145,7 @@ export const prepareVaultManagerKit = (
);

// push initial state of metrics
helper.updateMetrics();
void helper.updateMetrics();

void observeNotifier(periodNotifier, {
updateState: updateTime =>
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/auction/test-auctionContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,8 @@ test.serial('onDeadline exit, with chainStorage RPC snapshot', async t => {
await assertPayouts(t, liqSeat, currency, collateral, 116n, 0n);

await driver.advanceTo(186n, 'wait');
scheduleTracker.assertNoUpdate();
bookTracker.assertNoUpdate();
void scheduleTracker.assertNoUpdate();
void bookTracker.assertNoUpdate();

await driver.advanceTo(210n, 'wait');
await scheduleTracker.assertChange({
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/auction/test-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ test('change Schedule', async t => {

const newFreq = 100n;
const newStep = 40n;
paramManager.updateParams({
void paramManager.updateParams({
StartFrequency: TimeMath.toRel(newFreq, timerBrand),
ClockStep: TimeMath.toRel(newStep, timerBrand),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function start(zcf, privateArgs, baggage) {
runBrand,
);
let storedCollateralQuote;
observeNotifier(quoteNotifier, {
void observeNotifier(quoteNotifier, {
updateState(value) {
storedCollateralQuote = value;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/notifier/src/stored-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const makeStoredNotifier = (notifier, storageNode, marshaller) => {

const marshallToStorage = makeSerializeToStorage(storageNode, marshaller);

observeNotifier(notifier, {
void observeNotifier(notifier, {
updateState(value) {
marshallToStorage(value).catch(reason =>
console.error('StoredNotifier failed to updateState', reason),
Expand Down
Loading

0 comments on commit cd3a199

Please sign in to comment.