From 9f24519610f7e93cbd658638a6c100d8caad3059 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Fri, 11 Oct 2024 14:34:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Adds=20actor=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent_dart_base/test/agent/actor.dart | 33 ++++++++++++++++++- .../agent_dart_base/test/agent/agent.dart | 6 +++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/agent_dart_base/test/agent/actor.dart b/packages/agent_dart_base/test/agent/actor.dart index cfe4b73f..c046205b 100644 --- a/packages/agent_dart_base/test/agent/actor.dart +++ b/packages/agent_dart_base/test/agent/actor.dart @@ -1,7 +1,38 @@ +import 'package:agent_dart_base/agent_dart_base.dart'; +import 'package:test/test.dart'; + void main() { actorTest(); } void actorTest() { - /// skip, see https://github.com/dfinity/agent-js/blob/main/packages/agent/src/actor.test.ts + test('actor', () async { + final agent = HttpAgent( + defaultHost: 'icp-api.io', + defaultPort: 443, + options: const HttpAgentOptions(identity: AnonymousIdentity()), + ); + final idl = IDL.Service({ + 'create_challenge': IDL.Func( + [], + [ + IDL.Record({ + 'png_base64': IDL.Text, + 'challenge_key': IDL.Text, + }), + ], + [], + ), + }); + final actor = CanisterActor( + ActorConfig( + canisterId: Principal.fromText('rdmx6-jaaaa-aaaaa-aaadq-cai'), + agent: agent, + ), + idl, + ); + final result = await actor.getFunc('create_challenge')!.call([]); + expect(result, isA()); + expect(result['challenge_key'], isA()); + }); } diff --git a/packages/agent_dart_base/test/agent/agent.dart b/packages/agent_dart_base/test/agent/agent.dart index 70a9bf4b..f46083b0 100644 --- a/packages/agent_dart_base/test/agent/agent.dart +++ b/packages/agent_dart_base/test/agent/agent.dart @@ -1,3 +1,5 @@ +import '../test_utils.dart'; +import 'actor.dart' as actor; import 'cbor.dart' as cbor; import 'certificate.dart' as certificate; import 'request_id.dart' as request_id; @@ -6,10 +8,12 @@ import 'utils/hash.dart' as hash; import 'utils/leb128.dart' as leb128; void main() { + ffiInit(); + actor.main(); + cbor.main(); certificate.main(); request_id.main(); bls.main(); hash.main(); leb128.main(); - cbor.main(); }