Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/indexer/test/IndexerNotifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ describe.skip("IndexerNotifier", () => {
await sendTransactions(appChain, 2);
}, 20000);

afterAll(async () => {
await appChain.close();
});

it("should create a task for every unproven block produced", async () => {
const { block } = container
.resolve(IndexBlockTaskParametersSerializer)
Expand Down
32 changes: 21 additions & 11 deletions packages/processor/test/HandlersExecutor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,37 @@ const alice = alicePrivateKey.toPublicKey();

const bobPrivateKey = PrivateKey.random();
const bob = bobPrivateKey.toPublicKey();
function createAppChain() {
const appChain = TestingAppChain.fromRuntime({
Balances: Balances,
});

appChain.configurePartial({
Runtime: {
Balances: {},
},
});
return appChain;
}
describe("HandlersModule", () => {
it("should handle blocks", async () => {
const appChain = TestingAppChain.fromRuntime({
Balances: Balances,
});
let appChain: ReturnType<typeof createAppChain>;

appChain.configurePartial({
Runtime: {
Balances: {},
},
});
it("should handle blocks", async () => {
appChain = createAppChain();

await appChain.start();

const trackBalanceOnBlockHandler: BlockHandler<PrismaClient> = async (
client,
{ block, result: blockResult }
) => {
const app = appChain;
// iterate over all transactions
for (const tx of block.transactions) {
const methodId = tx.tx.methodId.toBigInt();

const methodDescriptor =
appChain.runtime.methodIdResolver.getMethodNameFromId(methodId);
app.runtime.methodIdResolver.getMethodNameFromId(methodId);

if (methodDescriptor === undefined) {
throw new Error("Unable to retrieve the method descriptor");
Expand All @@ -56,7 +62,7 @@ describe("HandlersModule", () => {

const handleBalancesTransferSigned = async () => {
console.log("handleBalancesTransferSigned");
const module = appChain.runtime.resolve("Balances");
const module = app.runtime.resolve("Balances");

const parameterDecoder = MethodParameterEncoder.fromMethod(
module,
Expand Down Expand Up @@ -176,4 +182,8 @@ describe("HandlersModule", () => {
expect(balance.address).toBe(alice.toBase58());
expect(balance.amount).toBe("0");
});

afterAll(async () => {
await appChain.close();
});
});
63 changes: 36 additions & 27 deletions packages/sdk/test/TestingAppChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,38 @@ class CustomBalances extends Balances<BalancesConfig> {
public foo() {}
}

function createAppChain(sender: PublicKey) {
const appChain = TestingAppChain.fromRuntime({
Admin,
Balances: CustomBalances,
});

appChain.configurePartial({
Runtime: {
Admin: {
admin: sender,
},

Balances: {
totalSupply: UInt64.from(1000),
},
},
Protocol: {
...appChain.config.Protocol!,
TransactionFee: {
tokenId: 0n,
feeRecipient: PrivateKey.random().toPublicKey().toBase58(),
baseFee: 0n,
perWeightUnitFee: 0n,
methods: {},
},
},
});
return appChain;
}

describe("testing app chain", () => {
let appChain: ReturnType<typeof createAppChain>;
it("should enable a complete transaction roundtrip", async () => {
expect.assertions(2);

Expand All @@ -90,33 +121,7 @@ describe("testing app chain", () => {
* Setup the app chain for testing purposes,
* using the provided runtime modules
*/
const appChain = TestingAppChain.fromRuntime({
Admin,
Balances: CustomBalances,
});

appChain.configurePartial({
Runtime: {
Admin: {
admin: sender,
},

Balances: {
totalSupply: UInt64.from(1000),
},
},
Protocol: {
...appChain.config.Protocol!,
TransactionFee: {
tokenId: 0n,
feeRecipient: PrivateKey.random().toPublicKey().toBase58(),
baseFee: 0n,
perWeightUnitFee: 0n,
methods: {},
},
},
});

appChain = createAppChain(sender);
// start the chain, sequencer is now accepting transactions
await appChain.start();

Expand Down Expand Up @@ -158,4 +163,8 @@ describe("testing app chain", () => {

expect(balance?.toBigInt()).toBe(1000n);
}, 60_000);

afterAll(async () => {
await appChain.close();
});
});
4 changes: 4 additions & 0 deletions packages/sdk/test/XYK/XYK.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ describe("xyk", () => {
xyk = chain.runtime.resolve("XYK");
}, 60_000);

afterAll(async () => {
await chain.close();
});

it("should mint balance for alice", async () => {
expect.assertions(2);

Expand Down
31 changes: 19 additions & 12 deletions packages/sdk/test/blockProof/blockProof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,32 @@ import { TestingAppChain } from "../../src/testing/TestingAppChain";

import { TestBalances } from "./TestBalances";

function createAppChain(totalSupply: UInt64) {
const appChain = TestingAppChain.fromRuntime({
Balances: TestBalances,
});

appChain.configurePartial({
Runtime: {
Balances: {
totalSupply,
},
},
});

return appChain;
}
// Failing - investigate why
describe.skip("blockProof", () => {
let appChain: ReturnType<typeof createAppChain>;
it("should transition block state hash", async () => {
expect.assertions(3);

const merklestore = new MockAsyncMerkleTreeStore();
const tree = new RollupMerkleTree(merklestore.store);

const totalSupply = UInt64.from(10_000);

const appChain = TestingAppChain.fromRuntime({
Balances: TestBalances,
});

appChain.configurePartial({
Runtime: {
Balances: {
totalSupply,
},
},
});
appChain = createAppChain(totalSupply);

await appChain.start();

Expand Down Expand Up @@ -143,5 +148,7 @@ describe.skip("blockProof", () => {

expect(block?.transactions[0].status.toBoolean()).toBe(true);
expect(aliceBalance?.toBigInt()).toBe(1000n);

await appChain.close();
}, 120_000);
});
63 changes: 36 additions & 27 deletions packages/sdk/test/fee-hook-sts-regression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,39 @@ class CustomBalances extends Balances<BalancesConfig> {
// @runtimeMethod()
public foo() {}
}
function createAppChain(sender: PublicKey) {
const appChain = TestingAppChain.fromRuntime({
Admin,
Balances: CustomBalances,
});

appChain.configurePartial({
Runtime: {
Admin: {
admin: sender,
},

Balances: {
totalSupply: UInt64.from(10000),
},
},
Protocol: {
...appChain.config.Protocol!,
TransactionFee: {
tokenId: 0n,
feeRecipient: PrivateKey.random().toPublicKey().toBase58(),
baseFee: 0n,
perWeightUnitFee: 0n,
methods: {},
},
},
});

return appChain;
}

describe("testing app chain", () => {
let appChain: ReturnType<typeof createAppChain>;
it("should enable a complete transaction roundtrip", async () => {
expect.assertions(4);

Expand All @@ -90,33 +121,7 @@ describe("testing app chain", () => {
* Setup the app chain for testing purposes,
* using the provided runtime modules
*/
const appChain = TestingAppChain.fromRuntime({
Admin,
Balances: CustomBalances,
});

appChain.configurePartial({
Runtime: {
Admin: {
admin: sender,
},

Balances: {
totalSupply: UInt64.from(10000),
},
},
Protocol: {
...appChain.config.Protocol!,
TransactionFee: {
tokenId: 0n,
feeRecipient: PrivateKey.random().toPublicKey().toBase58(),
baseFee: 0n,
perWeightUnitFee: 0n,
methods: {},
},
},
});

appChain = createAppChain(sender);
// start the chain, sequencer is now accepting transactions
await appChain.start();

Expand Down Expand Up @@ -178,4 +183,8 @@ describe("testing app chain", () => {

expect(balance?.toBigInt()).toBe(2000n);
}, 60_000);

afterAll(async () => {
await appChain.close();
});
});
Loading
Loading