Skip to content

Commit 9f24519

Browse files
committed
🧪 Adds actor tests
1 parent 3122f00 commit 9f24519

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1+
import 'package:agent_dart_base/agent_dart_base.dart';
2+
import 'package:test/test.dart';
3+
14
void main() {
25
actorTest();
36
}
47

58
void actorTest() {
6-
/// skip, see https://github.com/dfinity/agent-js/blob/main/packages/agent/src/actor.test.ts
9+
test('actor', () async {
10+
final agent = HttpAgent(
11+
defaultHost: 'icp-api.io',
12+
defaultPort: 443,
13+
options: const HttpAgentOptions(identity: AnonymousIdentity()),
14+
);
15+
final idl = IDL.Service({
16+
'create_challenge': IDL.Func(
17+
[],
18+
[
19+
IDL.Record({
20+
'png_base64': IDL.Text,
21+
'challenge_key': IDL.Text,
22+
}),
23+
],
24+
[],
25+
),
26+
});
27+
final actor = CanisterActor(
28+
ActorConfig(
29+
canisterId: Principal.fromText('rdmx6-jaaaa-aaaaa-aaadq-cai'),
30+
agent: agent,
31+
),
32+
idl,
33+
);
34+
final result = await actor.getFunc('create_challenge')!.call([]);
35+
expect(result, isA<Map>());
36+
expect(result['challenge_key'], isA<String>());
37+
});
738
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '../test_utils.dart';
2+
import 'actor.dart' as actor;
13
import 'cbor.dart' as cbor;
24
import 'certificate.dart' as certificate;
35
import 'request_id.dart' as request_id;
@@ -6,10 +8,12 @@ import 'utils/hash.dart' as hash;
68
import 'utils/leb128.dart' as leb128;
79

810
void main() {
11+
ffiInit();
12+
actor.main();
13+
cbor.main();
914
certificate.main();
1015
request_id.main();
1116
bls.main();
1217
hash.main();
1318
leb128.main();
14-
cbor.main();
1519
}

0 commit comments

Comments
 (0)