Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cda102643 | ||
|
|
25df41460e | ||
|
|
04d176eb55 |
@@ -22,7 +22,7 @@ jobs:
|
|||||||
path: "./laconicd/"
|
path: "./laconicd/"
|
||||||
repository: cerc-io/laconicd
|
repository: cerc-io/laconicd
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: main
|
ref: mainnet
|
||||||
- name: Environment
|
- name: Environment
|
||||||
run: ls -tlh && env
|
run: ls -tlh && env
|
||||||
|
|
||||||
|
|||||||
+18
-15
@@ -67,10 +67,13 @@ const auctionTests = () => {
|
|||||||
test('Commit bids.', async () => {
|
test('Commit bids.', async () => {
|
||||||
for (let i = 0; i < numBidders; i++) {
|
for (let i = 0; i < numBidders; i++) {
|
||||||
bidAmounts.push((LOWEST_BID_AMOUNT + (i * 500)).toString());
|
bidAmounts.push((LOWEST_BID_AMOUNT + (i * 500)).toString());
|
||||||
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccounts[i].address, `${bidAmounts[i]}${DENOM}`);
|
|
||||||
await registry.commitBid({ auctionId, commitHash: bidderAccounts[i].bid.commitHash }, bidderAccounts[i].privateKey, fee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all(bidderAccounts.map(async (bidderAccount, i) => {
|
||||||
|
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccount.address, `${bidAmounts[i]}${DENOM}`);
|
||||||
|
return registry.commitBid({ auctionId, commitHash: bidderAccount.bid.commitHash }, bidderAccount.privateKey, fee);
|
||||||
|
}));
|
||||||
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('commit');
|
expect(auction.status).toEqual('commit');
|
||||||
expect(auction.bids.length).toEqual(3);
|
expect(auction.bids.length).toEqual(3);
|
||||||
@@ -90,9 +93,9 @@ const auctionTests = () => {
|
|||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('reveal');
|
expect(auction.status).toEqual('reveal');
|
||||||
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
await Promise.all(bidderAccounts.map(async bidderAccount => {
|
||||||
await registry.revealBid({ auctionId, reveal: bidderAccounts[i].bid.revealString }, bidderAccounts[i].privateKey, fee);
|
return registry.revealBid({ auctionId, reveal: bidderAccount.bid.revealString }, bidderAccount.privateKey, fee);
|
||||||
}
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Check bids are revealed', async () => {
|
test('Check bids are revealed', async () => {
|
||||||
@@ -175,7 +178,7 @@ const providerAuctionTestsWithBids = (bidAmounts: number[], numProviders: number
|
|||||||
const otherAcc = await Account.generateFromMnemonic(mnenonic3);
|
const otherAcc = await Account.generateFromMnemonic(mnenonic3);
|
||||||
await otherAcc.init();
|
await otherAcc.init();
|
||||||
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: CREATOR_INITIAL_BALANCE.toString(), destinationAddress: otherAcc.address }, privateKey, fee);
|
await registry.sendCoins({ denom: DENOM, amount: BIDDER_INITIAL_BALANCE.toString(), destinationAddress: otherAcc.address }, privateKey, fee);
|
||||||
otherAccount = { address: otherAcc.address, privateKey: otherAcc.privateKey.toString('hex') };
|
otherAccount = { address: otherAcc.address, privateKey: otherAcc.privateKey.toString('hex') };
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -205,10 +208,10 @@ const providerAuctionTestsWithBids = (bidAmounts: number[], numProviders: number
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Commit bids.', async () => {
|
test('Commit bids.', async () => {
|
||||||
for (let i = 0; i < numBidders; i++) {
|
await Promise.all(bidderAccounts.map(async (bidderAccount, i) => {
|
||||||
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccounts[i].address, `${bidAmounts[i]}${DENOM}`);
|
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccount.address, `${bidAmounts[i]}${DENOM}`);
|
||||||
await registry.commitBid({ auctionId, commitHash: bidderAccounts[i].bid.commitHash }, bidderAccounts[i].privateKey, fee);
|
return registry.commitBid({ auctionId, commitHash: bidderAccount.bid.commitHash }, bidderAccount.privateKey, fee);
|
||||||
}
|
}));
|
||||||
|
|
||||||
sortedBidders = bidderAccounts.slice().sort((a, b) => {
|
sortedBidders = bidderAccounts.slice().sort((a, b) => {
|
||||||
return parseInt(a.bid.reveal.bidAmount) - parseInt(b.bid.reveal.bidAmount);
|
return parseInt(a.bid.reveal.bidAmount) - parseInt(b.bid.reveal.bidAmount);
|
||||||
@@ -239,21 +242,21 @@ const providerAuctionTestsWithBids = (bidAmounts: number[], numProviders: number
|
|||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('reveal');
|
expect(auction.status).toEqual('reveal');
|
||||||
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
await Promise.all(bidderAccounts.map(async bidderAccount => {
|
||||||
try {
|
try {
|
||||||
await registry.revealBid(
|
await registry.revealBid(
|
||||||
{ auctionId, reveal: bidderAccounts[i].bid.revealString },
|
{ auctionId, reveal: bidderAccount.bid.revealString },
|
||||||
bidderAccounts[i].privateKey,
|
bidderAccount.privateKey,
|
||||||
fee
|
fee
|
||||||
);
|
);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (invalidBidderAddress === bidderAccounts[i].address) {
|
if (bidderAccount.address === invalidBidderAddress) {
|
||||||
expect(error.toString()).toContain(INVALID_BID_ERROR);
|
expect(error.toString()).toContain(INVALID_BID_ERROR);
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Check bids are revealed', async () => {
|
test('Check bids are revealed', async () => {
|
||||||
|
|||||||
+5
-5
@@ -23,7 +23,7 @@ const configTests = () => {
|
|||||||
|
|
||||||
test('StdFee fees with gas price not set', async () => {
|
test('StdFee fees with gas price not set', async () => {
|
||||||
const testFees = {
|
const testFees = {
|
||||||
amount: [{ denom: 'alnt', amount: '400000' }],
|
amount: [{ denom: DENOM, amount: '400000' }],
|
||||||
gas: '400000'
|
gas: '400000'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,12 +37,12 @@ const configTests = () => {
|
|||||||
|
|
||||||
test('StdFee fees with gas price set', async () => {
|
test('StdFee fees with gas price set', async () => {
|
||||||
const testFees = {
|
const testFees = {
|
||||||
amount: [{ denom: 'alnt', amount: '400000' }],
|
amount: [{ denom: DENOM, amount: '400000' }],
|
||||||
gas: '400000'
|
gas: '400000'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set gas price lower than min gas price
|
// Set gas price lower than min gas price
|
||||||
const testGasPrice = GasPrice.fromString(String('0.00001alnt'));
|
const testGasPrice = GasPrice.fromString(`0.00001${DENOM}`);
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
||||||
|
|
||||||
// Send a bond creation tx
|
// Send a bond creation tx
|
||||||
@@ -55,7 +55,7 @@ const configTests = () => {
|
|||||||
|
|
||||||
test('Gas price with fees not set (default gas estimation multiplier)', async () => {
|
test('Gas price with fees not set (default gas estimation multiplier)', async () => {
|
||||||
// Set gas price
|
// Set gas price
|
||||||
const testGasPrice = GasPrice.fromString('1alnt');
|
const testGasPrice = GasPrice.fromString(`1${DENOM}`);
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
||||||
|
|
||||||
// Send a bond creation tx
|
// Send a bond creation tx
|
||||||
@@ -70,7 +70,7 @@ const configTests = () => {
|
|||||||
const testFees = 2.1;
|
const testFees = 2.1;
|
||||||
|
|
||||||
// Set gas price
|
// Set gas price
|
||||||
const testGasPrice = GasPrice.fromString('1alnt');
|
const testGasPrice = GasPrice.fromString(`1${DENOM}`);
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
||||||
|
|
||||||
// Send a bond creation tx
|
// Send a bond creation tx
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export const DENOM = 'alnt';
|
export const DENOM = 'alps';
|
||||||
export const DEFAULT_GAS_ESTIMATION_MULTIPLIER = 2;
|
export const DEFAULT_GAS_ESTIMATION_MULTIPLIER = 2;
|
||||||
|
|
||||||
export const AUCTION_KIND_VICKREY = 'vickrey';
|
export const AUCTION_KIND_VICKREY = 'vickrey';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|||||||
import yaml from 'node-yaml';
|
import yaml from 'node-yaml';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
|
|
||||||
import { Account, Registry } from '../index';
|
import { Account, DENOM } from '../index';
|
||||||
|
|
||||||
const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export const getConfig = () => {
|
|||||||
rpcEndpoint: process.env.LACONICD_RPC_ENDPOINT || 'http://localhost:26657',
|
rpcEndpoint: process.env.LACONICD_RPC_ENDPOINT || 'http://localhost:26657',
|
||||||
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
||||||
fee: {
|
fee: {
|
||||||
amount: [{ denom: 'alnt', amount: '200000' }],
|
amount: [{ denom: DENOM, amount: '200000' }],
|
||||||
gas: '200000'
|
gas: '200000'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user