Skip to content

Commit

Permalink
ci: add missing assertions, entitycount and fieldequals
Browse files Browse the repository at this point in the history
  • Loading branch information
banasa44 committed Apr 5, 2024
1 parent d35f1ba commit 0e2d3cc
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/subgraph/tests/plugin/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('Plugin', () => {
// check the entities are not in the store
assert.entityCount('MultisigProposal', 0);
assert.entityCount('Action', 0);
assert.entityCount('MultisigPlugin', 0);

// create state
createMultisigPluginState();
Expand Down Expand Up @@ -135,6 +136,7 @@ describe('Plugin', () => {
// check that the proposal action was created
assert.entityCount('Action', 1);
assert.entityCount('MultisigProposal', 1);
assert.entityCount('MultisigPlugin', 1);

// checks
assert.fieldEquals(
Expand Down Expand Up @@ -252,6 +254,10 @@ describe('Plugin', () => {

describe('handleApproved', () => {
test('handles the event', () => {
// check the entities are not in the store
assert.entityCount('MultisigProposalApprover', 0);
assert.entityCount('MultisigProposal', 0);

// create state
let proposal = createMultisigProposalEntityState(
proposalEntityId,
Expand Down Expand Up @@ -288,6 +294,10 @@ describe('Plugin', () => {

handleApproved(event);

// check if the proposal was approved
assert.entityCount('MultisigProposal', 1);
assert.entityCount('MultisigProposalApprover', 1);

// checks
const memberAddress = ADDRESS_ONE;

Expand Down Expand Up @@ -361,6 +371,10 @@ describe('Plugin', () => {

handleApproved(event2);

// check if the proposal was approved
assert.entityCount('MultisigProposal', 1);
assert.entityCount('MultisigProposalApprover', 2);

// Check
assert.fieldEquals('MultisigProposal', proposal.id, 'approvals', TWO);
assert.fieldEquals(
Expand All @@ -374,6 +388,9 @@ describe('Plugin', () => {

describe('handleProposalExecuted', () => {
test('handles the event', () => {
// check the entities are not in the store
assert.entityCount('MultisigProposal', 0);

// create state
createMultisigProposalEntityState(
proposalEntityId,
Expand All @@ -388,13 +405,22 @@ describe('Plugin', () => {
// handle event
handleProposalExecuted(event);

// check the proposal was executed
assert.entityCount('MultisigProposal', 1);

// checks
assert.fieldEquals(
'MultisigProposal',
proposalEntityId,
'id',
proposalEntityId
);
assert.fieldEquals(
'MultisigProposal',
proposalEntityId,
'approvalReached',
'false'
);
assert.fieldEquals(
'MultisigProposal',
proposalEntityId,
Expand Down Expand Up @@ -424,6 +450,9 @@ describe('Plugin', () => {

describe('handleMembersAdded', () => {
test('handles the event', () => {
// check the entities are not in the store
assert.entityCount('MultisigApprover', 0);

let memberAddresses = [ADDRESS_ONE, ADDRESS_TWO];

// create event
Expand All @@ -435,6 +464,9 @@ describe('Plugin', () => {
// handle event
handleMembersAdded(event);

// check members were added
assert.entityCount('MultisigApprover', 2);

// checks
let memberId =
CONTRACT_ADDRESS.toHexString() + '_' + memberAddresses[0].toHexString();
Expand All @@ -457,6 +489,9 @@ describe('Plugin', () => {

describe('handleMembersRemoved', () => {
test('handles the event', () => {
// check the entities are not in the store
assert.entityCount('MultisigProposal', 0);

// create state
let memberAddresses = [ADDRESS_ONE, ADDRESS_TWO];

Expand All @@ -469,6 +504,9 @@ describe('Plugin', () => {
// handle event
handleMembersAdded(addEvent);

// check members were added
assert.entityCount('MultisigApprover', 2);

// checks
let memberId1 =
CONTRACT_ADDRESS.toHexString() + '_' + memberAddresses[0].toHexString();
Expand All @@ -487,6 +525,9 @@ describe('Plugin', () => {
// handle event
handleMembersRemoved(removeEvent);

// check members were removed
assert.entityCount('MultisigApprover', 1);

// checks
assert.fieldEquals('MultisigApprover', memberId1, 'id', memberId1);
assert.notInStore('MultisigApprover', memberId2);
Expand All @@ -495,6 +536,9 @@ describe('Plugin', () => {

describe('handleMultisigSettingsUpdated', () => {
test('handles the event', () => {
// check the entities are not in the store
assert.entityCount('MultisigPlugin', 0);

// create state
let entityID = createMultisigPluginState().id;

Expand All @@ -511,6 +555,9 @@ describe('Plugin', () => {
// handle event
handleMultisigSettingsUpdated(event);

// check the entities are updated
assert.entityCount('MultisigPlugin', 1);

// checks
assert.fieldEquals(
'MultisigPlugin',
Expand Down

0 comments on commit 0e2d3cc

Please sign in to comment.