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

get_transactions bug, fail with Natural subtraction underflow #21

Open
ic-dstar opened this issue Dec 13, 2023 · 2 comments
Open

get_transactions bug, fail with Natural subtraction underflow #21

ic-dstar opened this issue Dec 13, 2023 · 2 comments

Comments

@ic-dstar
Copy link
Contributor

ic-dstar commented Dec 13, 2023

If It has 3 transactions, call get_transactions fail with Natural subtraction underflow.
you can test it if set a length less than start (by search inside transactions).

// dfx call
call get_transactions '(record{start=2 : nat; length=1 : nat})'

the bug cause by this line.

txs_in_canister:= SB.slice(transactions, tx_start_index, req.length);

function SB.sclice accept argument (buffer, start, end)

StableBuffer with slice = func<A>(buffer : T.StableBuffer<A>, start : Nat, end : Nat) : [A] {

but the code call it , SB.slice(transactions, tx_start_index, req.length).

it should fix to


SB.slice(transactions, tx_start_index,  tx_start_index + req.length).

could you fix this? or may I pull a request.

@tomijaga
Copy link
Member

Hey @ic-dstar,
Thanks for reporting the issue.

Feel free to submit a pull request so it can be quickly resolved.
I'll add more extensive tests for the get_transactions() fn later to prevent future errors.

@tomijaga
Copy link
Member

tomijaga commented Dec 15, 2023

Hey @ic-dstar,
Your PR has been merged into the main branch.
Let me know if any other issue comes up.

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

No branches or pull requests

2 participants