Skip to content

Commit

Permalink
Add test for mgmt canister request ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Mar 27, 2024
1 parent 68dee1e commit 32ef18a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 2 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
26 changes: 26 additions & 0 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 32ef18a

Please sign in to comment.