@@ -107,7 +107,7 @@ pub const PublicKey = extern struct {
107107 & address ,
108108 );
109109 if (result != 0 ) {
110- log .print ("failed to create program address with seeds {any} and program id {f}: error code {f }" , .{
110+ log .print ("failed to create program address with seeds {any} and program id {f}: error code {d }" , .{
111111 seeds ,
112112 program_id ,
113113 result ,
@@ -170,7 +170,7 @@ pub const PublicKey = extern struct {
170170 & pda .bump_seed [0 ],
171171 );
172172 if (result != 0 ) {
173- log .print ("failed to find program address given seeds {any} and program id {f}: error code {f }" , .{
173+ log .print ("failed to find program address given seeds {any} and program id {f}: error code {d }" , .{
174174 seeds ,
175175 program_id ,
176176 result ,
@@ -230,13 +230,26 @@ test "public_key: comptime create program address" {
230230 try testing .expectFmt ("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ" , "{f}" , .{address });
231231}
232232
233+ test "public_key: create program address" {
234+ const id = comptime PublicKey .comptimeFromBase58 ("11111111111111111111111111111111" );
235+ const address = try PublicKey .createProgramAddress (.{ "hello" , &.{255 } }, id );
236+ try testing .expectFmt ("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ" , "{f}" , .{address });
237+ }
238+
233239test "public_key: comptime find program address" {
234240 const id = comptime PublicKey .comptimeFromBase58 ("11111111111111111111111111111111" );
235241 const pda = comptime PublicKey .comptimeFindProgramAddress (.{"hello" }, id );
236242 try testing .expectFmt ("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ" , "{f}" , .{pda .address });
237243 try comptime testing .expectEqual (@as (u8 , 255 ), pda .bump_seed [0 ]);
238244}
239245
246+ test "public_key: find program address" {
247+ const id = comptime PublicKey .comptimeFromBase58 ("11111111111111111111111111111111" );
248+ const pda = try PublicKey .findProgramAddress (.{"hello" }, id );
249+ try testing .expectFmt ("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ" , "{f}" , .{pda .address });
250+ try testing .expectEqual (@as (u8 , 255 ), pda .bump_seed [0 ]);
251+ }
252+
240253test "public_key: equality" {
241254 const id = comptime PublicKey .comptimeFromBase58 ("11111111111111111111111111111111" );
242255 const id2 = comptime PublicKey .comptimeFromBase58 ("11111111111111111111111111111111" );
0 commit comments