Skip to content
Open
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
93 changes: 93 additions & 0 deletions subgraph/tests/metaBoard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "matchstick-as";
import {
createNewMetaV1Event,
handleNewMetaV1Events,
CONTRACT_ADDRESS,
OTHER_CONTRACT_ADDRESS,
} from "./utils";
Expand Down Expand Up @@ -391,3 +392,95 @@ describe("Test MetaV1 ids are scoped to their metaboard", () => {
assert.bigIntEquals(board.nextMetaId, BigInt.fromI32(2));
});
});

const firstCounterTransactionHash =
"0x1111111111111111111111111111111111111111111111111111111111111111";
const secondCounterTransactionHash =
"0x2222222222222222222222222222222222222222222222222222222222222222";
const thirdCounterTransactionHash =
"0x3333333333333333333333333333333333333333333333333333333333333333";

describe("Test MetaBoard nextMetaId counter", () => {
afterEach(() => {
clearStore();
clearInBlockStore();
});

test("nextMetaId counts one per meta the board has seen", () => {
handleNewMetaV1Events([
createNewMetaV1Event(
CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
firstCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
createNewMetaV1Event(
CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
secondCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
createNewMetaV1Event(
CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
thirdCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
]);

assert.entityCount(ENTITY_TYPE_META_BOARD, 1);
assert.entityCount(ENTITY_TYPE_META_V1, 3);

const board = MetaBoard.load(CONTRACT_ADDRESS) as MetaBoard;
assert.bigIntEquals(board.nextMetaId, BigInt.fromI32(3));
});

// Cross-board MetaV1 identity is #206's; this asserts only the counters.
test("Each metaboard counts only its own metas", () => {
handleNewMetaV1Events([
createNewMetaV1Event(
CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
firstCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
createNewMetaV1Event(
OTHER_CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
secondCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
createNewMetaV1Event(
CONTRACT_ADDRESS,
sender,
subject,
Bytes.fromHexString(metaString),
thirdCounterTransactionHash,
transactionBlockNumber,
transactionTimestamp,
),
]);

assert.entityCount(ENTITY_TYPE_META_BOARD, 2);

const board = MetaBoard.load(CONTRACT_ADDRESS) as MetaBoard;
const otherBoard = MetaBoard.load(OTHER_CONTRACT_ADDRESS) as MetaBoard;
assert.bigIntEquals(board.nextMetaId, BigInt.fromI32(2));
assert.bigIntEquals(otherBoard.nextMetaId, BigInt.fromI32(1));
});
});
Loading