algorand / go-algorand-sdk

Algorand Golang SDK
https://pkg.go.dev/github.com/algorand/go-algorand-sdk/v2
MIT License
185 stars 95 forks source link

Simulate: Fix simulate request error & support ATC simulation #611

Closed jasonpaulos closed 11 months ago

jasonpaulos commented 11 months ago

A user reported that the following error occurred when trying to use the algod simulate endpoint:

HTTP 400: {"message":"failed to decode object: json decode error [pos 13]: no matching struct field found when decoding stream map with key Format"}

I reproduced the error and saw that it was because the simulate endpoint needed to be added to rawRequestPaths, otherwise the code uses the query params as the POST body. This required a code generation change as well: https://github.com/algorand/generator/pull/68

In order to add coverage, I enabled the @simulate cucumber tests and added the necessary step defs.

Note that these tests also cover simulating with the AtomicTransactionComposer, which this SDK didn't support. Instead of modifying the test tags to separate this out (and updating the other SDKs' tags), I ended up implementing the missing feature instead.