Skip to content

Commit

Permalink
Return error on mgmt canister query.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Jun 7, 2024
1 parent 55528cc commit 786e084
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 0 additions & 20 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/aviate-labs/agent-go"
"github.com/aviate-labs/agent-go/candid/idl"
"github.com/aviate-labs/agent-go/certification/hashtree"
"github.com/aviate-labs/agent-go/ic"
ic0 "github.com/aviate-labs/agent-go/ic/ic"
Expand Down Expand Up @@ -119,25 +118,6 @@ func TestAgent_Call(t *testing.T) {
}
}

func TestAgent_Call_bitcoinGetBalanceQuery(t *testing.T) {
a, err := ic0.NewAgent(ic.MANAGEMENT_CANISTER_PRINCIPAL, agent.DefaultConfig)
if err != nil {
t.Fatal(err)
}
r, err := a.BitcoinGetBalanceQuery(ic0.BitcoinGetBalanceQueryArgs{
Address: "bc1qruu3xmfrt4nzkxax3lpxfmjega87jr3vqcwjn9",
Network: ic0.BitcoinNetwork{
Mainnet: new(idl.Null),
},
})
if err != nil {
t.Fatal(err)
}
if r == nil {
t.Fatal()
}
}

func TestAgent_Call_provisionalTopUpCanister(t *testing.T) {
a, err := ic0.NewAgent(ic.MANAGEMENT_CANISTER_PRINCIPAL, agent.DefaultConfig)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func (q Query) Query(values ...any) error {

for _, signature := range resp.Signatures {
if len(q.effectiveCanisterID.Raw) == 0 {
// TODO: temporary fix, signed queries did not take query calls from the management canister into account...
return nil
return fmt.Errorf("can not verify signature without effective canister ID")
}
c, err := q.a.readStateCertificate(q.effectiveCanisterID, [][]hashtree.Label{{hashtree.Label("subnet")}})
if err != nil {
Expand Down

0 comments on commit 786e084

Please sign in to comment.