Skip to content

Commit

Permalink
fix: removed unused from test-cateCoin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
amessbee committed May 15, 2024
1 parent 1741446 commit 022209e
Showing 1 changed file with 111 additions and 151 deletions.
262 changes: 111 additions & 151 deletions contract/test/test-cateCoin.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,57 @@

import { test as anyTest } from './prepare-test-env-ava.js';
// Imports the 'test' function from a local file './prepare-test-env-ava.js'.

import { createRequire } from 'module';
import { E } from '@endo/far';
import { makeCopyBag, M } from '@endo/patterns';

import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
import { makeZoeKitForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { AmountMath, makeIssuerKit, AssetKind } from '@agoric/ertp';
import { AmountMath } from '@agoric/ertp';
// Imports various modules needed for the tests.

import { makeStableFaucet } from './mintStable.js';
// import { makeStableFaucet } from './mintStable.js';
// import {
// startSellConcertTicketsContract,
// makeInventory,
// makeTerms,
// permit,
// } from '../src/sell-concert-tickets.proposal.js';
import { start } from '../src/cateCoin.contract.js';
import { getBundleId } from '../tools/bundle-tools.js';
import { mockBootstrapPowers } from './boot-tools.js';
import {
produceBoardAuxManager,
permit as boardAuxPermit,
} from '../src/platform-goals/board-aux.core.js';
import { extract } from '@agoric/vats/src/core/utils.js';
// import { start } from '../src/cateCoin.contract.js';
// import { getBundleId } from '../tools/bundle-tools.js';
// import { mockBootstrapPowers } from './boot-tools.js';
// import {
// produceBoardAuxManager,
// permit as boardAuxPermit,
// } from '../src/platform-goals/board-aux.core.js';
// import { extract } from '@agoric/vats/src/core/utils.js';
// Imports modules and functions for specific test scenarios.

/** @typedef {typeof import('../src/sell-concert-tickets.contract.js').start} AssetContractFn */
// Defines the type of 'AssetContractFn'.
import { test as anyTest } from './prepare-test-env-ava.js';

const myRequire = createRequire(import.meta.url);
const contractPath = myRequire.resolve(
`../src/cateCoin.contract.js`,
);
const contractPath = myRequire.resolve(`../src/cateCoin.contract.js`);

const test = anyTest;
// Renames the imported 'test' function for use in the file.

const UNIT6 = 1_000_000n;
const CENT = UNIT6 / 100n;
// Defines constants for unit values.

/**
* Tests assume access to the zoe service and that contracts are bundled.
*
* See test-bundle-source.js for basic use of bundleSource().
* Here we use a bundle cache to optimize running tests multiple times.
*
* @param {unknown} _t
*/
// Provides an overview of test assumptions and setup context.


const makeTestContext = async _t => {
// Defines a function to create test context.
const { zoeService: zoe, feeMintAccess } = makeZoeKitForTest();
// Creates a Zoe service kit for testing.

const bundleCache = await makeNodeBundleCache('bundles/', {}, nodeModuleSpecifier => import(nodeModuleSpecifier));
// Creates a node bundle cache instance with the specified options and import function.
const bundle = await bundleCache.load(contractPath, 'assetContract');

const installation = E(zoe).install(bundle);
// Defines a function to create test context.
const { zoeService: zoe, feeMintAccess } = makeZoeKitForTest();
// Creates a Zoe service kit for testing.

const bundleCache = await makeNodeBundleCache(
'bundles/',
{},
nodeModuleSpecifier => import(nodeModuleSpecifier),
);
// Creates a node bundle cache instance with the specified options and import function.
const bundle = await bundleCache.load(contractPath, 'assetContract');

E(zoe).install(bundle);
// Installs the contract bundle on Zoe.
//const { instance } = await E(zoe).startInstance(installation);
return { zoe, bundle, bundleCache, feeMintAccess };
// Returns the test context containing Zoe service, contract bundle, bundle cache, and fee mint access.
};
test.before(async t => (t.context = await makeTestContext(t)));
// Executes setup function before tests and assigns the context to 't'.
//const { instance } = await E(zoe).startInstance(installation);

Check failure on line 48 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

Expected space or tab after '//' in comment
return { zoe, bundle, bundleCache, feeMintAccess };
// Returns the test context containing Zoe service, contract bundle, bundle cache, and fee mint access.
};

test.before(async t => (t.context = await makeTestContext(t)));
// Executes setup function before tests and assigns the context to 't'.

test('Install CateCoin contract', async t => {
// Defines a test case to install the sell concert tickets contract.
Expand All @@ -89,7 +70,7 @@ test('Start CateCoin contract', async t => {
// Defines a test case to start contract.
const { zoe, bundle } = t.context;
// Destructures Zoe service and contract bundle from test context.

const installation = E(zoe).install(bundle);
// Installs the contract bundle on Zoe.
const { instance } = await E(zoe).startInstance(installation);
Expand All @@ -101,101 +82,80 @@ test('Start CateCoin contract', async t => {
});

test('createInitialCoins creates a fixed amount of initial CateCoin', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

const cateIssuer = await E(creatorFacet).getIssuer();
const cateBrand = await E(cateIssuer).getBrand();

const myPurse = await E(cateIssuer).makeEmptyPurse();

const coins = await E(creatorFacet).createInitialCoins(myPurse,100n);

// Creates a bag of tickets with different rows and quantities.
const amnt = await myPurse.getCurrentAmount();
const amnt2 = AmountMath.make(cateBrand, 100n);
t.true(
AmountMath.isEqual(
amnt,
amnt2
)
);
// Asserts that the calculated bag price matches the expected total price.
});

test('createInitialCoins CateCoin more than maxSupply', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

const cateIssuer = await E(creatorFacet).getIssuer();
const cateBrand = await E(cateIssuer).getBrand();
const myPurse = await E(cateIssuer).makeEmptyPurse();

const coins = await E(creatorFacet).createInitialCoins(myPurse,1000_001n);

// Creates a bag of tickets with different rows and quantities.
const amnt = await myPurse.getCurrentAmount()
const amnt2 = AmountMath.make(cateBrand, 0n)
t.true(
AmountMath.isEqual(
amnt,
amnt2
)
);
// Asserts that the calculated bag price matches the expected total price.
});

test('transferCateCoins two purses', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

const cateIssuer = await E(creatorFacet).getIssuer();
const fromPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).createInitialCoins(fromPurse,1000n);
const toPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 500n);
// Creates a bag of tickets with different rows and quantities.
const fromAmnt = await fromPurse.getCurrentAmount()
const toAmnt = await toPurse.getCurrentAmount()
t.true(
AmountMath.isEqual(
fromAmnt,
toAmnt
)
);
});
test('transferCateCoins more than sender has', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

const cateIssuer = await E(creatorFacet).getIssuer();
const fromPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).createInitialCoins(fromPurse,1000n);
const toPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 500n);
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 501n);
// Creates a bag of tickets with different rows and quantities.
const fromAmnt = await fromPurse.getCurrentAmount()
const toAmnt = await toPurse.getCurrentAmount()
t.true(
AmountMath.isEqual(
fromAmnt,
toAmnt
)
);
});

// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -

Check failure on line 88 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

Expected space or tab after '//' in comment
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

Check failure on line 90 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'instance' is assigned a value but never used. Allowed unused vars must match /^_/u

const cateIssuer = await E(creatorFacet).getIssuer();
const cateBrand = await E(cateIssuer).getBrand();

const myPurse = await E(cateIssuer).makeEmptyPurse();

const coins = await E(creatorFacet).createInitialCoins(myPurse, 100n);

Check failure on line 97 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'coins' is assigned a value but never used. Allowed unused vars must match /^_/u

// Creates a bag of tickets with different rows and quantities.
const amnt = await myPurse.getCurrentAmount();
const amnt2 = AmountMath.make(cateBrand, 100n);
t.true(AmountMath.isEqual(amnt, amnt2));
// Asserts that the calculated bag price matches the expected total price.
});

test('createInitialCoins CateCoin more than maxSupply', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

Check failure on line 110 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'instance' is assigned a value but never used. Allowed unused vars must match /^_/u

const cateIssuer = await E(creatorFacet).getIssuer();
const cateBrand = await E(cateIssuer).getBrand();
const myPurse = await E(cateIssuer).makeEmptyPurse();

const coins = await E(creatorFacet).createInitialCoins(myPurse, 1000_001n);

Check failure on line 116 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'coins' is assigned a value but never used. Allowed unused vars must match /^_/u

// Creates a bag of tickets with different rows and quantities.
const amnt = await myPurse.getCurrentAmount();
const amnt2 = AmountMath.make(cateBrand, 0n);
t.true(AmountMath.isEqual(amnt, amnt2));
// Asserts that the calculated bag price matches the expected total price.
});

test('transferCateCoins two purses', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -

Check failure on line 129 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

Expected space or tab after '//' in comment
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

Check failure on line 131 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'instance' is assigned a value but never used. Allowed unused vars must match /^_/u

const cateIssuer = await E(creatorFacet).getIssuer();
const fromPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).createInitialCoins(fromPurse, 1000n);
const toPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 500n);
// Creates a bag of tickets with different rows and quantities.
const fromAmnt = await fromPurse.getCurrentAmount();
const toAmnt = await toPurse.getCurrentAmount();
t.true(AmountMath.isEqual(fromAmnt, toAmnt));
});
test('transferCateCoins more than sender has', async t => {
// Defines a test case to calculate the total price for a bag of tickets.
const { zoe, bundle } = t.context;

//Does not work here -

Check failure on line 147 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

Expected space or tab after '//' in comment
const installation = E(zoe).install(bundle);
const { instance, creatorFacet } = await E(zoe).startInstance(installation);

Check failure on line 149 in contract/test/test-cateCoin.js

View workflow job for this annotation

GitHub Actions / unit

'instance' is assigned a value but never used. Allowed unused vars must match /^_/u

const cateIssuer = await E(creatorFacet).getIssuer();
const fromPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).createInitialCoins(fromPurse, 1000n);
const toPurse = await E(cateIssuer).makeEmptyPurse();
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 500n);
await E(creatorFacet).transferCateCoins(fromPurse, toPurse, 501n);
// Creates a bag of tickets with different rows and quantities.
const fromAmnt = await fromPurse.getCurrentAmount();
const toAmnt = await toPurse.getCurrentAmount();
t.true(AmountMath.isEqual(fromAmnt, toAmnt));
});

0 comments on commit 022209e

Please sign in to comment.