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

chores/212 additional ordinals tests #217

Closed
wants to merge 6 commits into from

Conversation

jeremy-babylonlabs
Copy link
Contributor

No description provided.

@jeremy-babylonlabs jeremy-babylonlabs force-pushed the chores/212-additional-ordinals-tests branch from 8b23838 to 1890cfd Compare July 25, 2024 13:01
@jeremy-babylonlabs jeremy-babylonlabs self-assigned this Jul 25, 2024
@jeremy-babylonlabs jeremy-babylonlabs marked this pull request as ready for review July 25, 2024 17:21
}

// Test case 3: Invalid UTXO txid should return an error
func TestVerifyUtxosEndpointWithMixedUTXOs(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

aren't we checking the txId at the handler level? Why do we need to mock the unisat and ordinal service response if the request will return error at handler layer?

mockUnisat.On("FetchInscriptionsUtxosByAddress", mock.Anything, mock.Anything, mock.Anything).
Return(mockUnisatResponse, nil).Once()
mockUnisat.On("FetchInscriptionsUtxosByAddress", mock.Anything, mock.Anything, mock.Anything).
Return([]*unisat.UnisatUTXO{}, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the purpose here to test the unisat pagination? then it would be best to have at least 1 item returned fromt he second response.
also it would be better to replace the mock.Anything with the actual cursor and limit value so that we ensure the pagination works

}

for _, u := range response.Data {
unisatUTXO, exists := unisatUTXOMap[u.TxId]
Copy link
Collaborator

@jrwbabylonlab jrwbabylonlab Jul 29, 2024

Choose a reason for hiding this comment

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

this is not true. Unisat does not return all utxos.
unisat only return the utxos that has ordinals for a particular address.
I.e len(response.Data) != len(unisat response).

}

// Test case 5: Unisat service return error, return error
func TestVerifyUtxosEndpointUnisatServiceErrorReturnError(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: could you double check if we using UTXOs or Utxos in the codebase. I don't remember

callCount := 0
var mockUnisatResponses [][]*unisat.UnisatUTXO
mockUnisat := new(mocks.UnisatClientInterface)
mockUnisat.On("FetchInscriptionsUtxosByAddress", mock.Anything, mock.Anything, mock.Anything).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure the below tests are relevant to us.
What i thought this test would be is:

  1. Override the config c.config.limit to be a much smaller number
  2. Send a post request
  3. the mocked response from unisat return c.config.limit many item.
  4. triggered another call, that return the remaining items. so in total, we have over c.config.limit items from unisat
  5. based on all the returned values from unisat, filter the post request utxos

@@ -336,3 +336,5 @@ func buildActiveStakingEvent(t *testing.T, numOfEvenet int) []*client.ActiveStak
}
return activeStakingEvents
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: one more extra line

@jrwbabylonlab
Copy link
Collaborator

addressed in other PR

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.

2 participants