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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aristidesstaffieri
Copy link

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
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
Author

Choose a reason for hiding this comment

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

updated in 90f7d32


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

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