Skip to content
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

[services][feat] #81: Add test for ingesting path payments #84

Merged
merged 4 commits into from
Dec 2, 2024

Conversation

aristidesstaffieri
Copy link
Contributor

Closes #81

What

Add test for ingest of path payments

Why

Current test cases only cover regular payments

Known limitations

N/A

Issue that this PR addresses

#81

PR Structure

  • It is not possible to break this PR down into smaller PRs.
  • This PR does not mix refactoring changes with feature changes.
  • This PR's title starts with name of package that is most changed in the PR, or all if the changes are broad or impact many packages.

Thoroughness

  • This PR adds tests for the new functionality or fixes.
  • All updated queries have been tested (refer to this check if the data set returned by the updated query is expected to be same as the original one).

Release

  • This is not a breaking change.
  • This is ready to be tested in development.
  • The new functionality is gated with a feature flag if this is not ready for production.

@aristidesstaffieri aristidesstaffieri requested a review from a team November 27, 2024 17:17
@aristidesstaffieri aristidesstaffieri self-assigned this Nov 27, 2024
@@ -215,3 +216,166 @@ func TestIngestPayments(t *testing.T) {
assert.Equal(t, payments[0].TransactionHash, "abcd")
})
}

func TestIngestPathPaymentsSend(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this a unit test under the TestIngestPayments function? With a t.Run("op_pat_payment_send", func(t *testing.T) { ...} ? That way you can also reuse the same set up code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good call. Updated in 90f7d32

})
}

func TestIngestPathPaymentsReceive(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Can you make this a unit test under the TestIngestPayments function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in 90f7d32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, I removed this and all instances you mentioned in 0b1637c


t.Run("test_op_path_payment_send", func(t *testing.T) {
err := models.Account.Insert(context.Background(), srcAccount)
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking here but I don't really think you require this line. This is not a test to see if models are working. I'd replace it with _ := models.Account.Insert(context.Background(), srcAccount)

Operations: []txnbuild.Operation{&pathPaymentOp},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(10)},
})
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. This can be replaced with:

	transaction, _ := txnbuild.NewTransaction(txnbuild.TransactionParams{
		SourceAccount: &txnbuild.SimpleAccount{
			AccountID: keypair.MustRandom().Address(),
		},
		Operations:    []txnbuild.Operation{&pathPaymentOp},
		Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(10)},
	})


signer := keypair.MustRandom()
errSigner := models.Account.Insert(context.Background(), signer.Address())
require.NoError(t, errSigner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

require.NoError(t, errSigner)

signedTx, err := transaction.Sign(network.TestNetworkPassphrase, signer)
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

require.NoError(t, err)

txEnvXDR, err := signedTx.Base64()
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


t.Run("test_op_path_payment_receive", func(t *testing.T) {
err := models.Account.Insert(context.Background(), srcAccount)
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Operations: []txnbuild.Operation{&pathPaymentOp},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(10)},
})
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


signer := keypair.MustRandom()
errSigner := models.Account.Insert(context.Background(), signer.Address())
require.NoError(t, errSigner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

require.NoError(t, errSigner)

signedTx, err := transaction.Sign(network.TestNetworkPassphrase, signer)
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

require.NoError(t, err)

txEnvXDR, err := signedTx.Base64()
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@aristidesstaffieri aristidesstaffieri merged commit c1db94b into main Dec 2, 2024
5 checks passed
@aristidesstaffieri aristidesstaffieri deleted the expand-ingest-tests branch December 2, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand tests for ingestPayments
2 participants