From 786e084d2babf93b3e187a040e6ee0f975db489b Mon Sep 17 00:00:00 2001 From: Quint Daenen Date: Fri, 7 Jun 2024 10:51:16 +0200 Subject: [PATCH] Return error on mgmt canister query. --- agent_test.go | 20 -------------------- query.go | 3 +-- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/agent_test.go b/agent_test.go index b686871..f52eab7 100644 --- a/agent_test.go +++ b/agent_test.go @@ -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" @@ -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 { diff --git a/query.go b/query.go index af861dc..bdc2deb 100644 --- a/query.go +++ b/query.go @@ -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 {