From ad0bbd8ae7e609f84e517abe61f0406a1fbcda64 Mon Sep 17 00:00:00 2001 From: Quint Daenen Date: Wed, 27 Mar 2024 10:46:11 +0100 Subject: [PATCH] Add test for mgmt canister request ids. --- request.go | 5 ++--- request_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/request.go b/request.go index aaff522..e3355fc 100644 --- a/request.go +++ b/request.go @@ -3,13 +3,12 @@ package agent import ( "bytes" "crypto/sha256" - "math/big" - "sort" - "github.com/aviate-labs/agent-go/certification/hashtree" "github.com/aviate-labs/agent-go/identity" "github.com/aviate-labs/agent-go/principal" "github.com/aviate-labs/leb128" + "math/big" + "sort" "github.com/fxamacker/cbor/v2" ) diff --git a/request_test.go b/request_test.go index 21636ae..ecc2ebd 100644 --- a/request_test.go +++ b/request_test.go @@ -42,6 +42,32 @@ func TestNewRequestID(t *testing.T) { })); h != "ea01a9c3d3830db108e0a87995ea0d4183dc9c6e51324e9818fced5c57aa64f5" { t.Error(h) } + + if h := fmt.Sprintf("%x", agent.NewRequestID(agent.Request{ + Type: agent.RequestTypeCall, + Sender: principal.AnonymousID, + IngressExpiry: 1711532558242940000, + CanisterID: principal.Principal{Raw: make([]byte, 0)}, // aaaaa-aa + MethodName: "update_settings", + Arguments: []byte{ + // ic0.UpdateSettingsArgs{ + // CanisterId: "bkyz2-fmaaa-aaaaa-qaaaq-cai", + // Settings: ic0.CanisterSettings{ + // Controllers: &[]principal.Principal{ + // principal.AnonymousID, + // }, + // }, + // } + 0x44, 0x49, 0x44, 0x4c, 0x06, 0x6e, 0x7d, 0x6d, 0x68, 0x6e, 0x01, 0x6c, 0x05, 0xc0, 0xcf, 0xf2, + 0x71, 0x00, 0xd7, 0xe0, 0x9b, 0x90, 0x02, 0x02, 0x80, 0xad, 0x98, 0x8a, 0x04, 0x00, 0xde, 0xeb, + 0xb5, 0xa9, 0x0e, 0x00, 0xa8, 0x82, 0xac, 0xc6, 0x0f, 0x00, 0x6e, 0x78, 0x6c, 0x03, 0xb3, 0xc4, + 0xb1, 0xf2, 0x04, 0x68, 0xe3, 0xf9, 0xf5, 0xd9, 0x08, 0x03, 0xca, 0x99, 0x98, 0xb4, 0x0d, 0x04, + 0x01, 0x05, 0x01, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, + 0x01, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, + }, + })); h != "3599fd3f4505a6ec44429dddff35a3e1338d9d28c64444cf4632df427d83d3cf" { + t.Error(h) + } } func TestRequestID_Sign(t *testing.T) {