Skip to content

Commit

Permalink
update version and Zemu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jan 2, 2023
1 parent 23b8696 commit c60de9c
Show file tree
Hide file tree
Showing 93 changed files with 148 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=35
# This is the patch version of this release
APPVERSION_P=0
APPVERSION_P=1
Binary file added tests_zemu/snapshots/s-govDeposit/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-govDeposit/00012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00010.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00011.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00012.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00013.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00014.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00015.png
Binary file added tests_zemu/snapshots/s-setWithdrawAddress/00016.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00000.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00001.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00002.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00003.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00004.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00005.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00006.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00007.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00008.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00009.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00010.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00011.png
Binary file added tests_zemu/snapshots/sp-govDeposit/00012.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00000.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00001.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00002.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00003.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00004.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00005.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00006.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00007.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00008.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00009.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00010.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00011.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00012.png
Binary file added tests_zemu/snapshots/sp-setWithdrawAddress/00013.png
Binary file added tests_zemu/snapshots/x-govDeposit/00000.png
Binary file added tests_zemu/snapshots/x-govDeposit/00001.png
Binary file added tests_zemu/snapshots/x-govDeposit/00002.png
Binary file added tests_zemu/snapshots/x-govDeposit/00003.png
Binary file added tests_zemu/snapshots/x-govDeposit/00004.png
Binary file added tests_zemu/snapshots/x-govDeposit/00005.png
Binary file added tests_zemu/snapshots/x-govDeposit/00006.png
Binary file added tests_zemu/snapshots/x-govDeposit/00007.png
Binary file added tests_zemu/snapshots/x-govDeposit/00008.png
Binary file added tests_zemu/snapshots/x-govDeposit/00009.png
Binary file added tests_zemu/snapshots/x-govDeposit/00010.png
Binary file added tests_zemu/snapshots/x-govDeposit/00011.png
Binary file added tests_zemu/snapshots/x-govDeposit/00012.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00000.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00001.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00002.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00003.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00004.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00005.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00006.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00007.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00008.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00009.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00010.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00011.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00012.png
Binary file added tests_zemu/snapshots/x-setWithdrawAddress/00013.png
57 changes: 56 additions & 1 deletion tests_zemu/tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
******************************************************************************* */
import { DEFAULT_START_OPTIONS, DeviceModel } from '@zondax/zemu'
import {DEFAULT_KEY_DELAY} from "@zondax/zemu/src/constants";

const Resolve = require('path').resolve

Expand Down Expand Up @@ -245,3 +244,59 @@ export const ibc_denoms = {
],
sequence: '1'
}

export const setWithdrawAddress = {
account_number: '8',
chain_id: 'testing',
fee: {
amount: [
{
amount: '5000',
denom: 'uatom'
}
],
gas: '200000'
},
memo: '',
msgs: [
{
type: 'cosmos-sdk/MsgSetWithdrawAddress',
value: {
delegator_address: 'cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv',
withdraw_address: 'cosmos12d64j98tjjpqkx70r08aspc4nvntqp2w6wr2de'
}
},
{
type: 'cosmos-sdk/MsgWithdrawDelegationReward',
value: {
delegator_address: 'cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv',
validator_address: 'cosmosvaloper13dr26wdygna3s8fdl5tlc45m2le2ydyddxzj49'
}
}
],
sequence: '7'
}

export const cliGovDeposit = {
account_number: '8',
chain_id: 'my-chain',
fee: {
amount: [],
gas: '200000'
},
memo: 'A B C',
msgs: [
{
type: 'cosmos-sdk/MsgDeposit',
value: {
amount: [{
amount: '10',
denom: 'stake',
}],
depositor: 'cosmos1xl2256vdh0j68khz9wq88hnyqcq0f5f4za2480',
proposal_id: '1'
}
},
],
sequence: '2'
}
92 changes: 91 additions & 1 deletion tests_zemu/tests/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Zemu from '@zondax/zemu'
// @ts-ignore
import { CosmosApp } from '@zondax/ledger-cosmos-js'
import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms, AMINO_JSON_TX } from './common'
import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms, AMINO_JSON_TX, setWithdrawAddress, cliGovDeposit } from './common'

// @ts-ignore
import secp256k1 from 'secp256k1/elliptic'
Expand Down Expand Up @@ -215,4 +215,94 @@ describe('Json', function () {
await sim.close()
}
})

test.each(DEVICE_MODELS)('SetWithdrawAddress', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...DEFAULT_OPTIONS, model: m.name })
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = Buffer.from(JSON.stringify(setWithdrawAddress))

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
expect(respPk.return_code).toEqual(0x9000)
expect(respPk.error_message).toEqual('No errors')
console.log(respPk)

// do not wait here..
const signatureRequest = app.sign(path, tx, 0x0)

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-setWithdrawAddress`)

const resp = await signatureRequest
console.log(resp)

expect(resp.return_code).toEqual(0x9000)
expect(resp.error_message).toEqual('No errors')
expect(resp).toHaveProperty('signature')

// Now verify the signature
const hash = crypto.createHash('sha256')
const msgHash = Uint8Array.from(hash.update(tx).digest())

const signatureDER = resp.signature
const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER))

const pk = Uint8Array.from(respPk.compressed_pk)

const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk)
expect(signatureOk).toEqual(true)
} finally {
await sim.close()
}
})

test.each(DEVICE_MODELS)('CLIGovDeposit', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...DEFAULT_OPTIONS, model: m.name })
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = Buffer.from(JSON.stringify(cliGovDeposit))

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
expect(respPk.return_code).toEqual(0x9000)
expect(respPk.error_message).toEqual('No errors')
console.log(respPk)

// do not wait here..
const signatureRequest = app.sign(path, tx, 0x0)

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-govDeposit`)

const resp = await signatureRequest
console.log(resp)

expect(resp.return_code).toEqual(0x9000)
expect(resp.error_message).toEqual('No errors')
expect(resp).toHaveProperty('signature')

// Now verify the signature
const hash = crypto.createHash('sha256')
const msgHash = Uint8Array.from(hash.update(tx).digest())

const signatureDER = resp.signature
const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER))

const pk = Uint8Array.from(respPk.compressed_pk)

const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk)
expect(signatureOk).toEqual(true)
} finally {
await sim.close()
}
})
})

0 comments on commit c60de9c

Please sign in to comment.