Skip to content

Commit e43b4a0

Browse files
authored
public-key: Fix equals to actually work (#13)
1 parent 95404ad commit e43b4a0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.{
22
.fingerprint = 0xdc47aff950fd68c0,
33
.name = .solana_program_sdk,
4-
.version = "0.16.1",
4+
.version = "0.16.2",
55
.minimum_zig_version = "0.14.0",
66

77
// This field is optional.

src/public_key.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub const PublicKey = extern struct {
4747
}
4848

4949
pub fn equals(self: PublicKey, other: PublicKey) bool {
50-
return self.bytes == other.bytes;
50+
return std.mem.eql(u8, &self.bytes, &other.bytes);
5151
}
5252

5353
pub fn isPointOnCurve(self: PublicKey) bool {
@@ -238,3 +238,10 @@ test "public_key: comptime find program address" {
238238
try testing.expectFmt("2PjSSVURwJV4o9wz1BDVwwddvcUCuF1NKFpcQBF9emYJ", "{}", .{pda.address});
239239
try comptime testing.expectEqual(@as(u8, 255), pda.bump_seed[0]);
240240
}
241+
242+
test "public_key: equality" {
243+
const id = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
244+
const id2 = comptime PublicKey.comptimeFromBase58("11111111111111111111111111111111");
245+
try testing.expectEqual(id, id2);
246+
try testing.expect(id.equals(id2));
247+
}

0 commit comments

Comments
 (0)