Fix 4 pre-existing test bugs in transaction, parser, and wallet-sync tests

- transaction.test: getFeeMultiplier(0) expects 5n (priority 2/Normal)
    matching C++ wallet2.cpp fee algorithm >= 2, not 1n (priority 1)
  - transaction-parser.test: Add missing txType and rct_type bytes to
    minimal tx test data (Salvium prefix is longer than Monero's)
  - transaction-parser.test: Use txnFee (parser's field name) not fee
    in summarizeTransaction mock data
  - wallet-sync.test: Add getBlocksByHeight stub to MockDaemon so the
    existing individual-fetch fallback path is exercised
This commit is contained in:
Matt Hess
2026-02-01 04:20:08 +00:00
parent a8185b6e31
commit f026e4c824
3 changed files with 12 additions and 6 deletions
+5 -5
View File
@@ -287,7 +287,7 @@ test('summarizes basic transaction', () => {
},
rct: {
type: RCT_TYPE.BulletproofPlus,
fee: 10000000n,
txnFee: 10000000n,
outPk: [new Uint8Array(32), new Uint8Array(32)]
}
};
@@ -422,8 +422,8 @@ test('parseTransaction handles hex string input', () => {
});
test('parseTransaction extracts version', () => {
// version=2, unlock_time=0, vin_count=0, vout_count=0, extra_len=0
const txBytes = new Uint8Array([0x02, 0x00, 0x00, 0x00, 0x00]);
// version=2, unlock_time=0, vin_count=0, vout_count=0, extra_len=0, txType=0(UNSET), rct_type=0(Null)
const txBytes = new Uint8Array([0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
const tx = parseTransaction(txBytes);
@@ -431,8 +431,8 @@ test('parseTransaction extracts version', () => {
});
test('parseTransaction extracts unlock time', () => {
// version=2, unlock_time=100, vin_count=0, vout_count=0, extra_len=0
const txBytes = new Uint8Array([0x02, 0x64, 0x00, 0x00, 0x00]);
// version=2, unlock_time=100, vin_count=0, vout_count=0, extra_len=0, txType=0(UNSET), rct_type=0(Null)
const txBytes = new Uint8Array([0x02, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00]);
const tx = parseTransaction(txBytes);
+1 -1
View File
@@ -1109,7 +1109,7 @@ test('getFeeMultiplier returns correct values', () => {
});
test('getFeeMultiplier clamps out-of-range priorities', () => {
assertEqual(getFeeMultiplier(0), 1n); // Clamped to 1
assertEqual(getFeeMultiplier(0), 5n); // 0 defaults to priority 2 (Normal) per C++ wallet2.cpp
assertEqual(getFeeMultiplier(5), 1000n); // Clamped to 4
});
+6
View File
@@ -123,6 +123,12 @@ class MockDaemon {
};
}
async getBlocksByHeight(heights) {
this.callLog.push(`getBlocksByHeight([${heights.join(',')}])`);
// Return failure to trigger individual block fetch fallback
return { success: false };
}
async getTransactionPool() {
this.callLog.push('getTransactionPool');
return {