File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,3 +61,43 @@ export let storeServiceBinding = {
6161 }
6262 } ,
6363} ;
64+
65+ // Test that service stubs and actor classes can both be encoded into `props`, the stub with the
66+ // props can be sent over RPC, and it all still works.
67+ export class UsePropsTest extends WorkerEntrypoint {
68+ async run ( ) {
69+ let id = this . ctx . exports . MyActor . idFromName ( 'bar' ) ;
70+ let stub = this . ctx . exports . MyActor . get ( id ) ;
71+
72+ {
73+ await stub . put ( 'foo' , this . ctx . props . Greeter ) ;
74+ let greeter = await stub . get ( 'foo' ) ;
75+ assert . strictEqual ( await greeter . greet ( 'Alice' ) , 'Yo, Alice!' ) ;
76+ }
77+
78+ {
79+ await stub . put ( 'bar' , this . ctx . props . MyFacet ) ;
80+
81+ assert . strictEqual ( await stub . useFacet ( 'bar' ) , 'Hiya, Bob?' ) ;
82+ }
83+ }
84+ }
85+
86+ export let bindingsInProps = {
87+ async test ( controller , env , ctx ) {
88+ let stub = ctx . exports . UsePropsTest ( {
89+ props : {
90+ Greeter : ctx . exports . Greeter ( { props : { greeting : 'Yo' } } ) ,
91+ MyFacet : ctx . exports . MyFacet ( { props : { greeting : 'Hiya' } } ) ,
92+ } ,
93+ } ) ;
94+
95+ // Send stub over RPC so the props get encoded into a channel token with nested channel
96+ // tokens.
97+ await ctx . exports . bindingsInProps . run ( stub ) ;
98+ } ,
99+
100+ async run ( stub ) {
101+ await stub . run ( ) ;
102+ } ,
103+ } ;
Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ kj::Own<Frankenvalue::CapTableEntry> ChannelTokenHandler::decodeChannelTokenImpl
249249 capTable.add (decodeSubrequestChannelToken (usage, cap.getSubrequestChannel ()));
250250 continue ;
251251 case ChannelToken::FrankenvalueCapTable::Cap::ACTOR_CLASS_CHANNEL:
252- capTable.add (decodeSubrequestChannelToken (usage, cap.getActorClassChannel ()));
252+ capTable.add (decodeActorClassChannelToken (usage, cap.getActorClassChannel ()));
253253 continue ;
254254 }
255255 KJ_FAIL_REQUIRE (" unknown cap table type" , cap.which ());
You can’t perform that action at this time.
0 commit comments