Skip to content

Commit

Permalink
fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
EdNoepel committed Jul 18, 2023
1 parent 8bcf607 commit 0abfcbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function addressArrayToBytesArray(addresses: Address[]): Bytes[] {
}

export function bigIntToBytes(bi: BigInt): Bytes {
if (bi.isI32())
if (bi.isI32()) // HACK: handle padding oddities when converting BigInt which came from a signed number
return Bytes.fromByteArray(Bytes.fromBigInt(BigInt.fromI32(bi.toI32())))
else
return Bytes.fromByteArray(Bytes.fromBigInt(bi))
Expand Down
18 changes: 16 additions & 2 deletions tests/grant-fund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,19 @@ describe("Grant Fund assertions", () => {
Bytes.fromHexString("0x000000"),
Bytes.fromHexString("0x000000"),
];
const distributionId = BigInt.fromI32(234);
const startBlock = ONE_BI;
const endBlock = startBlock.plus(DISTRIBUTION_PERIOD_LENGTH);
const description = "test proposal";

// mock GrantFund contract calls
const distributionId = BigInt.fromI32(234);
const newDistributionPeriodStartedEvent = createDistributionPeriodStartedEvent(
distributionId,
startBlock,
endBlock
);
newDistributionPeriodStartedEvent.address = grantFundAddress
handleDistributionPeriodStarted(newDistributionPeriodStartedEvent);
mockGetDistributionId(grantFundAddress, distributionId);

// create mock event
Expand Down Expand Up @@ -235,12 +242,19 @@ describe("Grant Fund assertions", () => {
Bytes.fromHexString("0x000000"),
Bytes.fromHexString("0x000000"),
];
const distributionId = BigInt.fromI32(234);
const startBlock = ONE_BI;
const endBlock = startBlock.plus(DISTRIBUTION_PERIOD_LENGTH);
const description = "test proposal";

// mock GrantFund contract calls
const distributionId = BigInt.fromI32(234);
const newDistributionPeriodStartedEvent = createDistributionPeriodStartedEvent(
distributionId,
startBlock,
endBlock
);
newDistributionPeriodStartedEvent.address = grantFundAddress
handleDistributionPeriodStarted(newDistributionPeriodStartedEvent);
mockGetDistributionId(grantFundAddress, distributionId);

// create mock event
Expand Down

0 comments on commit 0abfcbc

Please sign in to comment.