Skip to content

Commit

Permalink
test: update matchstick tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Oct 18, 2023
1 parent 2abe800 commit c41e714
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@graphprotocol/client-cli": "^3.0.0",
"@graphprotocol/graph-cli": "0.56.0",
"@graphprotocol/graph-ts": "0.27.0",
"@graphprotocol/graph-ts": "0.31.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.4",
"@nomicfoundation/hardhat-toolbox": "^1.0.2",
Expand Down Expand Up @@ -67,7 +67,7 @@
"hardhat-gas-reporter": "^1.0.8",
"husky": "^3.0.5",
"lint-staged": "^12.3.3",
"matchstick-as": "^0.5.0",
"matchstick-as": "^0.6.0",
"module-alias": "^2.2.2",
"mustache": "^4.2.0",
"patch-package": "6.5.1",
Expand Down
10 changes: 4 additions & 6 deletions subgraphs/isolated-pools/tests/Pool/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
test,
} from 'matchstick-as/assembly';

import { Pool } from '../../generated/schema';
import { oneBigInt, zeroBigInt32 } from '../../src/constants';
import {
handleActionPausedMarket,
Expand Down Expand Up @@ -373,11 +374,8 @@ describe('Pool Events', () => {
comptrollerAddress.toHexString(),
);

assert.fieldEquals(
'Pool',
comptrollerAddress.toHex(),
'rewardsDistributors',
`[${rewardsDistributorAddress.toHexString()}]`,
);
const pool = Pool.load(comptrollerAddress.toHex())!;
const rewardsDistributors = pool.rewardsDistributors.load();
assert.stringEquals(rewardsDistributorAddress.toHexString(), rewardsDistributors[0].id);
});
});
19 changes: 7 additions & 12 deletions subgraphs/isolated-pools/tests/RewardsDistributor/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
test,
} from 'matchstick-as/assembly/index';

import { RewardsDistributor } from '../../generated/schema';
import { handleNewRewardsDistributor } from '../../src/mappings/pool';
import {
handleRewardTokenBorrowSpeedUpdated,
Expand Down Expand Up @@ -77,12 +78,9 @@ describe('Rewards Distributor', () => {
assert.fieldEquals('RewardSpeed', rewardId, 'supplySpeedPerBlockMantissa', '0');
assert.fieldEquals('RewardSpeed', rewardId, 'borrowSpeedPerBlockMantissa', newBorrowRate);

assert.fieldEquals(
'RewardsDistributor',
rewardsDistributorAddress.toHex(),
'rewardSpeeds',
`[${rewardId}]`,
);
const rewardsDistributor = RewardsDistributor.load(rewardsDistributorAddress.toHex())!;
const rewardSpeeds = rewardsDistributor.rewardSpeeds.load();
assert.stringEquals(rewardId, rewardSpeeds[0].id);
});

test('indexes new supply speed', () => {
Expand All @@ -107,11 +105,8 @@ describe('Rewards Distributor', () => {
assert.fieldEquals('RewardSpeed', rewardId, 'supplySpeedPerBlockMantissa', newSupplyRate);
assert.fieldEquals('RewardSpeed', rewardId, 'borrowSpeedPerBlockMantissa', '0');

assert.fieldEquals(
'RewardsDistributor',
rewardsDistributorAddress.toHex(),
'rewardSpeeds',
`[${rewardId}]`,
);
const rewardsDistributor = RewardsDistributor.load(rewardsDistributorAddress.toHex())!;
const rewardSpeeds = rewardsDistributor.rewardSpeeds.load();
assert.stringEquals(rewardId, rewardSpeeds[0].id);
});
});
9 changes: 5 additions & 4 deletions subgraphs/venus-governance/tests/unit/Alpha/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ProposalExecuted,
ProposalQueued,
} from '../../../generated/GovernorAlpha/GovernorAlpha';
import { Delegate } from '../../../generated/schema';
import { governorBravoDelegateAddress } from '../../../src/constants/addresses';
import {
handleProposalCanceled,
Expand Down Expand Up @@ -77,7 +78,10 @@ describe('Alpha', () => {
assertDelegateDocument('id', user1.toHexString());
assertDelegateDocument('totalVotesMantissa', '0');
assertDelegateDocument('delegateCount', '0');
assertDelegateDocument('proposals', '[1]');

const delegate = Delegate.load(user1.toHex())!;
const proposals = delegate.proposals.load();
assert.stringEquals('1', proposals[0].id);

// Proposal
const assertProposalDocument = (key: string, value: string): void => {
Expand All @@ -92,7 +96,6 @@ describe('Alpha', () => {
assertProposalDocument('startBlock', `${startBlock}`);
assertProposalDocument('endBlock', `${endBlock}`);
assertProposalDocument('description', description);
assertProposalDocument('status', 'PENDING');
});

test('cancel proposal', () => {
Expand Down Expand Up @@ -168,7 +171,5 @@ describe('Alpha', () => {
assertVoteDocument('votes', votes.toString());
assertVoteDocument('support', 'FOR');
assertVoteDocument('votes', votes.toString());

assert.fieldEquals('Proposal', '1', 'status', 'ACTIVE');
});
});
13 changes: 9 additions & 4 deletions subgraphs/venus-governance/tests/unit/Bravo/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ProposalExecuted,
ProposalQueued,
} from '../../../generated/GovernorBravoDelegate/GovernorBravoDelegate';
import { Delegate } from '../../../generated/schema';
import { governorBravoDelegateAddress } from '../../../src/constants/addresses';
import {
handleBravoVoteCast,
Expand Down Expand Up @@ -109,7 +110,10 @@ describe('Bravo', () => {
assertDelegateDocument('id', user1.toHexString());
assertDelegateDocument('totalVotesMantissa', '0');
assertDelegateDocument('delegateCount', '0');
assertDelegateDocument('proposals', '[1]');

const delegate = Delegate.load(user1.toHex())!;
const proposals = delegate.proposals.load();
assert.stringEquals('1', proposals[0].id);

// Proposal
const assertProposalDocument = (key: string, value: string): void => {
Expand Down Expand Up @@ -152,7 +156,10 @@ describe('Bravo', () => {
assertDelegateDocument('id', user1.toHexString());
assertDelegateDocument('totalVotesMantissa', '0');
assertDelegateDocument('delegateCount', '0');
assertDelegateDocument('proposals', '[1]');

const delegate = Delegate.load(user1.toHex())!;
const proposals = delegate.proposals.load();
assert.stringEquals('1', proposals[0].id);

// Proposal
const assertProposalDocument = (key: string, value: string): void => {
Expand Down Expand Up @@ -261,8 +268,6 @@ describe('Bravo', () => {
assertVoteDocument('votes', votes.toString());
assertVoteDocument('support', 'FOR');
assertVoteDocument('votes', votes.toString());

assert.fieldEquals('Proposal', '1', 'status', 'ACTIVE');
});

test('registers new implementation', () => {
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2448,12 +2448,12 @@ __metadata:
languageName: node
linkType: hard

"@graphprotocol/graph-ts@npm:0.27.0":
version: 0.27.0
resolution: "@graphprotocol/graph-ts@npm:0.27.0"
"@graphprotocol/graph-ts@npm:0.31.0":
version: 0.31.0
resolution: "@graphprotocol/graph-ts@npm:0.31.0"
dependencies:
assemblyscript: 0.19.10
checksum: d2916b9d0a8063ed3f00486012fd625301332fced8c9407f57908b43f0724d512c56b89b1c40e1cb67eca2ced9b1d437e237b04ab588b1d962573c301848a31a
checksum: 20394b17d3241a662f0b2efebdc02f44e4e0814fdbb09b4cac0c84b84a173798325840bc1daf1d11ebaf27b1b3e13ff6e2766567c755cb77c1321ba1462fbecc
languageName: node
linkType: hard

Expand Down Expand Up @@ -12297,12 +12297,12 @@ __metadata:
languageName: node
linkType: hard

"matchstick-as@npm:^0.5.0":
version: 0.5.2
resolution: "matchstick-as@npm:0.5.2"
"matchstick-as@npm:^0.6.0":
version: 0.6.0
resolution: "matchstick-as@npm:0.6.0"
dependencies:
wabt: 1.0.24
checksum: 6493b2c27e4e2d47397e111dd188ba637b76a46674b2165350f7f1571728acfae3bdb3e12c440ad0793853140aff4dca5bcd322eebe259074cc1fc508e2da926
checksum: 340025caf2fe677675d9e388f2726b9517dcd977e13c1d5d13517d3d72ebfe561ea849e5859df74e1ccf48559d5fe3a9bb7cce107187102ec9a3d0d677c596ff
languageName: node
linkType: hard

Expand Down Expand Up @@ -15749,7 +15749,7 @@ __metadata:
dependencies:
"@graphprotocol/client-cli": ^3.0.0
"@graphprotocol/graph-cli": 0.56.0
"@graphprotocol/graph-ts": 0.27.0
"@graphprotocol/graph-ts": 0.31.0
"@nomicfoundation/hardhat-chai-matchers": ^1.0.3
"@nomicfoundation/hardhat-network-helpers": ^1.0.4
"@nomicfoundation/hardhat-toolbox": ^1.0.2
Expand Down Expand Up @@ -15781,7 +15781,7 @@ __metadata:
hardhat-gas-reporter: ^1.0.8
husky: ^3.0.5
lint-staged: ^12.3.3
matchstick-as: ^0.5.0
matchstick-as: ^0.6.0
module-alias: ^2.2.2
mustache: ^4.2.0
patch-package: 6.5.1
Expand Down

0 comments on commit c41e714

Please sign in to comment.