diff --git a/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js b/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js index a5b8e921d81f..23d2e59f3af0 100755 --- a/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js +++ b/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js @@ -1,16 +1,3 @@ -#!/usr/bin/env node -/* eslint-env node */ -import { writeFile } from 'fs/promises'; -import { getInstanceBoardId } from '@agoric/synthetic-chain'; -import assert from 'node:assert/strict'; +import { recordAuctioneerInstance } from './vatDetails.js'; -const { env } = process; - -const oldAuctionInstance = await getInstanceBoardId('auctioneer'); -assert(oldAuctionInstance, 'no auction instance found'); -console.log('old auction instance ', oldAuctionInstance, env.HOME); - -await writeFile( - `${env.HOME}/.agoric/previousInstance.json`, - oldAuctionInstance, -); +await recordAuctioneerInstance(); diff --git a/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js b/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js index 7f50368d3a43..cc0655cc0143 100644 --- a/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js +++ b/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js @@ -16,10 +16,11 @@ import { pushPrices, USER1ADDR, } from '@agoric/synthetic-chain'; -import { readFile } from 'node:fs/promises'; -import { getDetailsMatchingVats } from './vatDetails.js'; - -const { env } = process; +import { readFile, rm } from 'node:fs/promises'; +import { + getDetailsMatchingVats, + lastAuctionInstancePathname, +} from './vatDetails.js'; const oraclesByBrand = new Map(); @@ -106,11 +107,9 @@ const verifyVaultPriceUpdate = async t => { }; const verifyAuctionInstance = async t => { - const newAuctionInstance = await getInstanceBoardId('auctioneer'); - const oldInstance = await readFile( - `${env.HOME}/.agoric/previousInstance.json`, - 'utf-8', - ); + const newAuctionInstance = getInstanceBoardId('auctioneer'); + const oldInstance = await readFile(lastAuctionInstancePathname, 'utf-8'); + await rm(lastAuctionInstancePathname); console.log( `new: ${newAuctionInstance} should be different from ${oldInstance}`, diff --git a/a3p-integration/proposals/a:vaults-auctions/vatDetails.js b/a3p-integration/proposals/a:vaults-auctions/vatDetails.js index 2cd4c2c949db..c7b545a26d5f 100644 --- a/a3p-integration/proposals/a:vaults-auctions/vatDetails.js +++ b/a3p-integration/proposals/a:vaults-auctions/vatDetails.js @@ -1,4 +1,10 @@ +/* eslint-env node */ +import { getInstanceBoardId } from '@agoric/synthetic-chain'; import dbOpenAmbient from 'better-sqlite3'; +import { writeFile } from 'fs/promises'; +import assert from 'node:assert/strict'; + +const { env } = process; const HOME = process.env.HOME; @@ -99,3 +105,13 @@ export const getDetailsMatchingVats = async vatName => { return infos; }; + +export const lastAuctionInstancePathname = `${env.HOME}/.agoric/lastAuctioneerInstance.json`; + +export const recordAuctioneerInstance = async () => { + const oldAuctionInstance = getInstanceBoardId('auctioneer'); + assert(oldAuctionInstance, 'no auction instance found'); + console.log('old auction instance ', oldAuctionInstance, env.HOME); + + await writeFile(lastAuctionInstancePathname, oldAuctionInstance); +};