-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Testing] Unit tests, E2E tests, logging and other Fixes / "Touchups" #253
Changes from 9 commits
913344a
2fcc881
27d9c3a
90d75bd
9181c56
d1659d6
da65f82
ddbd4d0
d2fe64e
8b235bc
b985910
2c03b25
c5bc8e7
8d0ec2f
d62858b
ebc0d6e
254568d
08236ac
69f9a9e
9228887
1a84277
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,20 +11,19 @@ import ( | |
"time" | ||
|
||
abci "github.com/cometbft/cometbft/abci/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pokt-network/poktroll/pkg/client/events" | ||
"github.com/pokt-network/poktroll/pkg/either" | ||
"github.com/pokt-network/poktroll/pkg/observable" | ||
"github.com/pokt-network/poktroll/pkg/observable/channel" | ||
"github.com/pokt-network/poktroll/testutil/testclient" | ||
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" | ||
"github.com/stretchr/testify/require" | ||
Olshansk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
const ( | ||
createClaimTimeoutDuration = 10 * time.Second | ||
eitherEventsReplayBufferSize = 100 | ||
msgClaimSenderQueryFmt = "tm.event='Tx' AND message.sender='%s'" | ||
msgClaimSenderQueryFmt = "tm.event='Tx' AND message.sender='%s' AND message.action='/pocket.supplier.MsgCreateClaim'" | ||
Olshansk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testServiceId = "anvil" | ||
eitherEventsBzReplayObsKey = "eitherEventsBzReplayObsKey" | ||
preExistingClaimsKey = "preExistingClaimsKey" | ||
|
@@ -86,17 +85,21 @@ func (s *suite) AfterTheSupplierCreatesAClaimForTheSessionForServiceForApplicati | |
func (s *suite) TheClaimCreatedBySupplierForServiceForApplicationShouldBePersistedOnchain(supplierName, serviceId, appName string) { | ||
ctx := context.Background() | ||
|
||
claimsRes, err := s.supplierQueryClient.AllClaims(ctx, &suppliertypes.QueryAllClaimsRequest{ | ||
allClaimsRes, err := s.supplierQueryClient.AllClaims(ctx, &suppliertypes.QueryAllClaimsRequest{ | ||
Filter: &suppliertypes.QueryAllClaimsRequest_SupplierAddress{ | ||
SupplierAddress: accNameToAddrMap[supplierName], | ||
}, | ||
}) | ||
require.NoError(s, err) | ||
require.NotNil(s, claimsRes) | ||
require.NotNil(s, allClaimsRes) | ||
|
||
// Assert that the number of claims has increased by one. | ||
preExistingClaims := s.scenarioState[preExistingClaimsKey].([]suppliertypes.Claim) | ||
require.Len(s, claimsRes.Claim, len(preExistingClaims)+1) | ||
// NB: We are avoiding the use of require.Len here because it provides unreadable output | ||
// TODO_TECHDEBT: Due to the speed of the blocks of the LocalNet sequencer, along with the small number | ||
// of blocks per session, multiple claims may be created throughout the duration of the test. Until | ||
// these values are appropriately adjusted | ||
require.Greater(s, len(allClaimsRes.Claim), len(preExistingClaims), "number of claims must have increased") | ||
Comment on lines
+98
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm less convinced that the part of the comment against usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
👍
I did experiment with When there's an error, it prints out the entire claims slice. This was an array of serialized protos and large in length, which looked incomprehensible on the screen and confusing to the reader. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did experiment with Lenf, but I did experiment with giving require.Len an unformatted string. I'm assuming one of those is suppose to be a "didn't". 😅 For the record, in other cases, I would argue that
|
||
|
||
// TODO_IMPROVE: assert that the root hash of the claim contains the correct | ||
// SMST sum. The sum can be retrieved by parsing the last 8 bytes as a | ||
|
@@ -106,7 +109,7 @@ func (s *suite) TheClaimCreatedBySupplierForServiceForApplicationShouldBePersist | |
// TODO_IMPROVE: add assertions about serviceId and appName and/or incorporate | ||
// them into the scenarioState key(s). | ||
|
||
claim := claimsRes.Claim[0] | ||
claim := allClaimsRes.Claim[0] | ||
require.Equal(s, accNameToAddrMap[supplierName], claim.SupplierAddress) | ||
} | ||
|
||
|
@@ -118,9 +121,9 @@ func (s *suite) TheSupplierHasServicedASessionWithRelaysForServiceForApplication | |
|
||
// Query for any existing claims so that we can compensate for them in the | ||
// future assertions about changes in on-chain claims. | ||
claimsRes, err := s.supplierQueryClient.AllClaims(ctx, &suppliertypes.QueryAllClaimsRequest{}) | ||
allClaimsRes, err := s.supplierQueryClient.AllClaims(ctx, &suppliertypes.QueryAllClaimsRequest{}) | ||
require.NoError(s, err) | ||
s.scenarioState[preExistingClaimsKey] = claimsRes.Claim | ||
s.scenarioState[preExistingClaimsKey] = allClaimsRes.Claim | ||
|
||
// Construct an events query client to listen for tx events from the supplier. | ||
msgSenderQuery := fmt.Sprintf(msgClaimSenderQueryFmt, accNameToAddrMap[supplierName]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
config: | ||
query_node_url: tcp://sequencer-poktroll-sequencer:36657 | ||
network_node_url: tcp://sequencer-poktroll-sequencer:36657 | ||
|
||
Olshansk marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the purposes of the E2E test, we also have the option to shortcut #180 by modifying existing step definitions (e.g.
#TheApplicationIsStakedForService
), or adding new step(s) (i.e. "given ..."), which do this staking against local/dev-netThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the comment but want to keep the actual change outside the scope of this PR.