Skip to content

Commit d228a1f

Browse files
committed
Fix stale RN test bindings and drop unused cdk dependency
Two follow-ups surfaced by the P2PK validation change: The koffi declaration in native.test.mjs still described the old ten-parameter ABI and omitted num_sigs_refund, so the sig_flag argument bound to the wrong slot and the call read a garbage eleventh argument, returning null. Update the declaration and its call sites to match the current C signature. The output-data-creator tests used a past locktime (1700000000) that the validated constructor now rejects; move them to a far-future value. Drop the cdk path dependency from the binding's Cargo.toml. The Rust source only uses cashu, and pulling in cdk forced Cargo to build cdk and its transitive dependencies for every native target with no benefit.
1 parent 6f3a243 commit d228a1f

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/react-native/rust/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ unwrap_used = "allow"
1818

1919
[dependencies]
2020
cashu = { path = "../../../crates/cashu" }
21-
cdk = { path = "../../../crates/cdk", default-features = false }

bindings/react-native/test/native.test.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const cdk_create_p2pk_blinded_message = lib.func(
6060
'const char **additional_pubkeys, uint32_t additional_pubkeys_len, ' +
6161
'uint64_t num_sigs, uint64_t locktime, ' +
6262
'const char **refund_pubkeys, uint32_t refund_pubkeys_len, ' +
63-
'const char *sig_flag)',
63+
'uint64_t num_sigs_refund, const char *sig_flag)',
6464
);
6565

6666
const cdk_create_deterministic_blinded_message = lib.func(
@@ -118,7 +118,7 @@ describe('cdk_create_p2pk_blinded_message', () => {
118118

119119
it('returns non-null for a valid pubkey', () => {
120120
const ptr = cdk_create_p2pk_blinded_message(
121-
1, KEYSET_ID, PUBKEY, null, 0, 1, 0, null, 0, 'SigInputs',
121+
1, KEYSET_ID, PUBKEY, null, 0, 1, 0, null, 0, 0, 'SigInputs',
122122
);
123123
assert.ok(ptr, 'result should not be null');
124124
const res = decode(ptr);
@@ -128,7 +128,7 @@ describe('cdk_create_p2pk_blinded_message', () => {
128128

129129
it('returns null for an invalid pubkey', () => {
130130
const ptr = cdk_create_p2pk_blinded_message(
131-
1, KEYSET_ID, 'not-a-key', null, 0, 1, 0, null, 0, 'SigInputs',
131+
1, KEYSET_ID, 'not-a-key', null, 0, 1, 0, null, 0, 0, 'SigInputs',
132132
);
133133
assert.equal(ptr, null, 'invalid pubkey should return null');
134134
});

bindings/react-native/test/output-data-creator.test.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ describe('createSingleP2PKData', () => {
121121
});
122122

123123
it('supports locktime', () => {
124-
const p2pk = { pubkey: TEST_PUBKEY, locktime: 1700000000 };
124+
// Far-future locktime; the validated constructor rejects past ones.
125+
const p2pk = { pubkey: TEST_PUBKEY, locktime: 4102444800 };
125126
const output = creator.createSingleP2PKData(p2pk, 1, KEYSET_ID);
126127

127-
assert.ok(output.secret.includes('1700000000'), 'locktime should appear in secret');
128+
assert.ok(output.secret.includes('4102444800'), 'locktime should appear in secret');
128129
});
129130

130131
it('supports multisig with additional pubkeys', () => {
@@ -143,12 +144,12 @@ describe('createSingleP2PKData', () => {
143144
const p2pk = {
144145
pubkey: TEST_PUBKEY,
145146
refundPubkeys: [TEST_PUBKEY],
146-
locktime: 1700000000,
147+
locktime: 4102444800,
147148
};
148149
const output = creator.createSingleP2PKData(p2pk, 1, KEYSET_ID);
149150

150151
assert.ok(output.secret.includes('P2PK'));
151-
assert.ok(output.secret.includes('1700000000'));
152+
assert.ok(output.secret.includes('4102444800'));
152153
});
153154
});
154155

0 commit comments

Comments
 (0)