Skip to content

Commit

Permalink
a3p vaults-auctions cleanup (#9977)
Browse files Browse the repository at this point in the history
refs: #9970

## Description
Follow up on #9970 that had merged while I was reviewing

### Security Considerations
none
### Scaling Considerations
none

### Documentation Considerations
none

### Testing Considerations
CI

### Upgrade Considerations
no additional
  • Loading branch information
mergify[bot] authored Sep 4, 2024
2 parents ebdf706 + eaf1323 commit bc8900d
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 273 deletions.
218 changes: 0 additions & 218 deletions a3p-integration/proposals/a:vaults-auctions/agd-tools.js

This file was deleted.

6 changes: 3 additions & 3 deletions a3p-integration/proposals/a:vaults-auctions/eval.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# we have an eval.sh so we can run prepare.sh before the rest
#!/bin/bash

echo "[$PROPOSAL] Running prepare.sh"
./prepare.sh
echo "[$PROPOSAL] Recording the auctioneer instance"
./saveAuctionInstance.js

echo "[$PROPOSAL] Running proposal declared in package.json"
# copy to run in the proposal package so the dependencies can be resolved
Expand Down
2 changes: 1 addition & 1 deletion a3p-integration/proposals/a:vaults-auctions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.1.0",
"@agoric/synthetic-chain": "^0.2.0",
"ava": "^5.3.1"
},
"ava": {
Expand Down
8 changes: 0 additions & 8 deletions a3p-integration/proposals/a:vaults-auctions/prepare.sh

This file was deleted.

14 changes: 2 additions & 12 deletions a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#!/usr/bin/env node
import { recordAuctioneerInstance } from './vatDetails.js';

import { writeFile } from 'fs/promises';
import { getAuctionInstance } from './agd-tools.js';

const { env } = process;

const oldAuctionInstance = await getAuctionInstance();
console.log('old auction instance ', oldAuctionInstance, env.HOME);

await writeFile(
`${env.HOME}/.agoric/previousInstance.json`,
oldAuctionInstance,
);
await recordAuctioneerInstance();
38 changes: 16 additions & 22 deletions a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
/* eslint-env node */
import test from 'ava';

import {
addPreexistingOracles,
agops,
ATOM_DENOM,
getISTBalance,
openVault,
USER1ADDR,
} from '@agoric/synthetic-chain';
import { readFile } from 'fs/promises';

import {
bankSend,
createBid,
getInstanceBoardId,
getISTBalance,
getLiveOffers,
getPriceQuote,
getVaultPrices,
openVault,
pushPrices,
addPreexistingOracles,
getAuctionInstance,
} from './agd-tools.js';
import { getDetailsMatchingVats } from './vatDetails.js';

const { env } = process;
USER1ADDR,
} from '@agoric/synthetic-chain';
import { readFile, rm } from 'node:fs/promises';
import {
getDetailsMatchingVats,
lastAuctionInstancePathname,
} from './vatDetails.js';

const oraclesByBrand = new Map();

Expand Down Expand Up @@ -108,19 +107,14 @@ const verifyVaultPriceUpdate = async t => {
};

const verifyAuctionInstance = async t => {
const newAuctionInstance = await getAuctionInstance();
const oldInstance = await readFile(
`${env.HOME}/.agoric/previousInstance.json`,
'utf-8',
);
const newAuctionInstance = await getInstanceBoardId('auctioneer');
const oldInstance = await readFile(lastAuctionInstancePathname, 'utf-8');
await rm(lastAuctionInstancePathname);

console.log(
`new: ${newAuctionInstance} should be different from ${oldInstance}`,
);
t.true(
newAuctionInstance !== oldInstance,
`new: ${newAuctionInstance} should be different from ${oldInstance}`,
);
t.not(newAuctionInstance, oldInstance);
};

// test.serial() isn't guaranteed to run tests in order, so we run the intended tests here
Expand Down
16 changes: 16 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/vatDetails.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 = await getInstanceBoardId('auctioneer');
assert(oldAuctionInstance, 'no auction instance found');
console.log('old auction instance ', oldAuctionInstance, env.HOME);

await writeFile(lastAuctionInstancePathname, oldAuctionInstance);
};
Loading

0 comments on commit bc8900d

Please sign in to comment.