Skip to content

Commit

Permalink
🧪 Adds actor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Oct 11, 2024
1 parent 3122f00 commit 9f24519
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
33 changes: 32 additions & 1 deletion packages/agent_dart_base/test/agent/actor.dart
Original file line number Diff line number Diff line change
@@ -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<Map>());
expect(result['challenge_key'], isA<String>());
});
}
6 changes: 5 additions & 1 deletion packages/agent_dart_base/test/agent/agent.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}

0 comments on commit 9f24519

Please sign in to comment.