Skip to content

Commit

Permalink
fix: handle missing schedule fields in inter auction status
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed May 18, 2023
1 parent 1902184 commit d23c5a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import { makeOfferSpecShape } from '@agoric/inter-protocol/src/auction/auctionBo
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { objectMap } from '@agoric/internal';
import { M, matches } from '@agoric/store';

// XXX scare away ambient type zombies to fix ScheduleNotification.activeStartTime etc.
// https://github.com/Agoric/agoric-sdk/issues/6512
// https://github.com/Agoric/agoric-sdk/issues/6343
import '@agoric/inter-protocol/src/vaultFactory/types.js';

import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
import {
asBoardRemote,
Expand Down Expand Up @@ -64,8 +70,12 @@ const makeFormatters = assets => {
const discount = r =>
r4(100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100);

/** @param {import('@agoric/time/src/types.js').TimestampRecord} tr */
const absTime = tr => new Date(Number(tr.absValue) * 1000).toISOString();
// XXX real TimeMath.absValue requires real Remotable timerBrand
/** @param {import('@agoric/time/src/types.js').Timestamp} ts */
const absValue = ts => (typeof ts === 'bigint' ? ts : ts.absValue);

/** @param {import('@agoric/time/src/types.js').Timestamp} tr */
const absTime = tr => new Date(Number(absValue(tr)) * 1000).toISOString();
/** @param {import('@agoric/time/src/types.js').RelativeTimeRecord} tr */
const relTime = tr =>
new Date(Number(tr.relValue) * 1000).toISOString().slice(11, 19);
Expand Down Expand Up @@ -290,8 +300,8 @@ inter auction status
const info = {
schedule: {
activeStartTime: fmt.absTimeOpt(schedule.activeStartTime),
nextStartTime: fmt.absTime(schedule.nextStartTime),
nextDescendingStepTime: fmt.absTime(
nextStartTime: fmt.absTimeOpt(schedule.nextStartTime),
nextDescendingStepTime: fmt.absTimeOpt(
schedule.nextDescendingStepTime,
),
},
Expand Down
23 changes: 23 additions & 0 deletions packages/agoric-cli/test/test-inter-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,29 @@ test('README: inter auction status', async t => {
const cmd = await makeInterCommand(makeProcess(t, testKeyring, out), net);
await cmd.parseAsync(argv);
t.deepEqual(JSON.parse(out.join('')), expected);

// schedule fields can be null
const auctionInfo2 = {
...auctionInfo,
schedule: {
_: {
activeStartTime: null,
nextDescendingStepTime: null,
nextStartTime: 1681875302n,
},
},
};

const { nextDescendingStepTime: _, ...schedule2 } = expected.schedule;
const net2 = makeNet({
...publishedNames,
auction: auctionInfo2,
});

out.splice(0);
const cmd2 = await makeInterCommand(makeProcess(t, testKeyring, out), net2);
await cmd2.parseAsync(argv);
t.deepEqual(JSON.parse(out.join('')), { ...expected, schedule: schedule2 });
});

test('README: inter vbank list', async t => {
Expand Down

0 comments on commit d23c5a0

Please sign in to comment.