From 0e2d3ccc8765c5d10bdbfd96fb123aabf66a5ea2 Mon Sep 17 00:00:00 2001 From: banasa44 Date: Fri, 5 Apr 2024 13:39:04 +0200 Subject: [PATCH] ci: add missing assertions, entitycount and fieldequals --- packages/subgraph/tests/plugin/plugin.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/packages/subgraph/tests/plugin/plugin.test.ts b/packages/subgraph/tests/plugin/plugin.test.ts index 3a3bbc1c..4fdbb26f 100644 --- a/packages/subgraph/tests/plugin/plugin.test.ts +++ b/packages/subgraph/tests/plugin/plugin.test.ts @@ -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(); @@ -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( @@ -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, @@ -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; @@ -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( @@ -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, @@ -388,6 +405,9 @@ describe('Plugin', () => { // handle event handleProposalExecuted(event); + // check the proposal was executed + assert.entityCount('MultisigProposal', 1); + // checks assert.fieldEquals( 'MultisigProposal', @@ -395,6 +415,12 @@ describe('Plugin', () => { 'id', proposalEntityId ); + assert.fieldEquals( + 'MultisigProposal', + proposalEntityId, + 'approvalReached', + 'false' + ); assert.fieldEquals( 'MultisigProposal', proposalEntityId, @@ -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 @@ -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(); @@ -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]; @@ -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(); @@ -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); @@ -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; @@ -511,6 +555,9 @@ describe('Plugin', () => { // handle event handleMultisigSettingsUpdated(event); + // check the entities are updated + assert.entityCount('MultisigPlugin', 1); + // checks assert.fieldEquals( 'MultisigPlugin',