Skip to content

Commit 385c047

Browse files
authored
Merge pull request #185 from Zondax/add_tests
2 parents b510ea7 + 0e092e9 commit 385c047

File tree

9 files changed

+25
-2
lines changed

9 files changed

+25
-2
lines changed

app/Makefile.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ APPVERSION_M=2
33
# This is the minor version of this release
44
APPVERSION_N=2
55
# This is the patch version of this release
6-
APPVERSION_P=0
6+
APPVERSION_P=1

deps/nanopb_tiny/pb_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ bool pb_field_iter_find_extension(pb_field_iter_t *iter) {
244244
advance_iterator(iter);
245245

246246
/* Do fast check for field type */
247-
fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info, iter->field_info_index);
247+
const pb_msgdesc_t *descriptor = (const pb_msgdesc_t *) PIC(iter->descriptor);
248+
fieldinfo = PB_PROGMEM_READU32(descriptor->field_info, iter->field_info_index);
248249

249250
if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION) {
250251
return load_descriptor_values(iter);
4 Bytes
Loading
4 Bytes
Loading
-8 Bytes
Loading
-8 Bytes
Loading
-8 Bytes
Loading
-8 Bytes
Loading

tests_zemu/tests/phase2b.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,26 @@ describe('Phase2', function () {
220220
await sim.close()
221221
}
222222
})
223+
224+
test.each(DEVICE_MODELS)('spawn neuron candid-protobuf invalid transactions', async function (m) {
225+
const sim = new Zemu(m.path)
226+
try {
227+
await sim.start({ ...DEFAULT_OPTIONS, model: m.name })
228+
const app = new InternetComputerApp(sim.getTransport())
229+
230+
const txBlobStr =
231+
'd9d9f7a167636f6e74656e74a76361726750620a10bcc7f5c8a3f293fb47220218326b63616e69737465725f69644a000000000000000101016e696e67726573735f6578706972791b172e706d8c61d2806b6d6574686f645f6e616d65706d616e6167655f6e6575726f6e5f7062656e6f6e63655000000184eb5a7ffab5d56eb72b8a04df6c726571756573745f747970656463616c6c6673656e646572581df1305df1b074e88adb99dc2f56f12d63208165f24dea7e60ae6cf6cf02'
232+
233+
const txBlob = Buffer.from(txBlobStr, 'hex')
234+
235+
const signatureResponse = await app.sign(path, txBlob, SIGN_VALUES_P2.DEFAULT)
236+
console.log(signatureResponse)
237+
238+
expect(signatureResponse.returnCode).toEqual(0x6984)
239+
expect(signatureResponse.errorMessage).toEqual('Data is invalid : Unexpected value')
240+
} finally {
241+
sim.dumpEvents()
242+
await sim.close()
243+
}
244+
})
223245
})

0 commit comments

Comments
 (0)