Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Dec 18, 2024
1 parent e23d803 commit 3609904
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 45 deletions.
22 changes: 3 additions & 19 deletions .github/scripts/changePrice.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,9 @@ const setAtomPrice = async (amount, containerName, agoricNet) => {
AGORIC_NET: agoricNet,
};

const { stdout } = await execa(
'docker',
[
'exec',
containerName,
agops,
'oracle',
'setPrice',
'--keys',
'gov1,gov2',
'--pair',
'ATOM.USD',
'--price',
amount,
'--keyring-backend',
'test',
],
{ env },
);
const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`;
const { stdout } = await execa('docker', ['exec', containerName, command], { env });

console.log('Standard output:', stdout);
} catch (error) {
console.error('Error:', error);
Expand Down
37 changes: 11 additions & 26 deletions .github/scripts/createVault.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,21 @@ import { execa } from 'execa';

const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops';

const createVault = async (containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral) => {
const createVault = async (containerName, agoricNet, userKey, wantMinted, giveCollateral) => {
console.log('Starting the vault creation process...');

if (!containerName || !agoricNet || !commandTimeout || !userKey || !wantMinted || !giveCollateral) {
console.error('Error: Missing one or more required parameters:', {
containerName,
agoricNet,
commandTimeout,
userKey,
wantMinted,
giveCollateral,
});
process.exit(1);
}

const createVaultCommand = `${agops} vaults open --wantMinted \"${wantMinted}\" --giveCollateral \"${giveCollateral}\" > /tmp/want-ist.json`;
const executeCreateVaultCommand = `docker exec ${containerName} /bin/bash -c "env AGORIC_NET=${agoricNet} timeout ${commandTimeout} ${createVaultCommand}"`;

try {
console.log(`Executing: ${executeCreateVaultCommand}`);
const { stdout: createVaultOutput } = await execa(executeCreateVaultCommand);
console.log('Vault creation output:', createVaultOutput);
const env = {
AGORIC_NET: agoricNet,
};

const command = `${agops} vaults open --wantMinted ${wantMinted} --giveCollateral ${giveCollateral} > /tmp/want-ist.json`;
await execa('docker', ['exec', containerName, `bash -c "${command}"`], { env });

console.log('Executing broadcast command...');
const broadcastCommand = `timeout ${commandTimeout} ${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`;
const executeBroadcastCommand = `docker exec ${containerName} bash -c "env AGORIC_NET=${agoricNet} ${broadcastCommand}"`;
const broadCastCommand = `${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`;
const { stdout } = await execa('docker', ['exec', containerName, broadCastCommand], { env });

const { stdout: broadcastOutput } = await execa(executeBroadcastCommand);
console.log('Broadcast output:', broadcastOutput);
console.log('Standard output:', stdout);
} catch (error) {
console.error('Error during vault creation:', error);
process.exit(1);
Expand All @@ -39,9 +25,8 @@ const createVault = async (containerName, agoricNet, commandTimeout, userKey, wa

const containerName = process.env.containerName;
const agoricNet = process.env.agoricNet;
const commandTimeout = process.env.commandTimeout;
const userKey = process.env.userKey;
const wantMinted = process.env.wantMinted;
const giveCollateral = process.env.giveCollateral;

createVault(containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral);
createVault(containerName, agoricNet, userKey, wantMinted, giveCollateral);

0 comments on commit 3609904

Please sign in to comment.