Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/public_key.zig
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub const PublicKey = extern struct {
&address,
);
if (result != 0) {
log.print("failed to create program address with seeds {any} and program id {f}: error code {f}", .{
log.print("failed to create program address with seeds {any} and program id {f}: error code {d}", .{
seeds,
program_id,
result,
Expand Down Expand Up @@ -170,7 +170,7 @@ pub const PublicKey = extern struct {
&pda.bump_seed[0],
);
if (result != 0) {
log.print("failed to find program address given seeds {any} and program id {f}: error code {f}", .{
log.print("failed to find program address given seeds {any} and program id {f}: error code {d}", .{
seeds,
program_id,
result,
Expand Down Expand Up @@ -230,13 +230,26 @@ test "public_key: comptime create program address" {
try testing.expectFmt("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ", "{f}", .{address});
}

test "public_key: create program address" {
const id = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
const address = try PublicKey.createProgramAddress(.{ "hello", &.{255} }, id);
try testing.expectFmt("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ", "{f}", .{address});
}

test "public_key: comptime find program address" {
const id = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
const pda = comptime PublicKey.comptimeFindProgramAddress(.{"hello"}, id);
try testing.expectFmt("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ", "{f}", .{pda.address});
try comptime testing.expectEqual(@as(u8, 255), pda.bump_seed[0]);
}

test "public_key: find program address" {
const id = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
const pda = try PublicKey.findProgramAddress(.{"hello"}, id);
try testing.expectFmt("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ", "{f}", .{pda.address});
try testing.expectEqual(@as(u8, 255), pda.bump_seed[0]);
}

test "public_key: equality" {
const id = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
const id2 = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
Expand Down
2 changes: 1 addition & 1 deletion src/rent.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub const Rent = struct {
};
const result = Syscall.sol_get_rent_sysvar(&rent);
if (result != 0) {
log.print("failed to get rent sysvar: error code {f}", .{result});
log.print("failed to get rent sysvar: error code {d}", .{result});
return error.Unexpected;
}
}
Expand Down