TST: spend from multisig test

This commit is contained in:
Overtorment 2020-11-05 17:17:27 +00:00
parent 7ae8a50753
commit 100099d28b
3 changed files with 124 additions and 10 deletions

View File

@ -443,6 +443,7 @@
"invalid_fingerprint": "Fingerprint for this seed doesnt match this cosigners fingerprint",
"view_edit_cosigners": "View/edit cosigners",
"this_cosigner_is_already_imported": "This cosigner is already imported",
"export_signed_psbt": "Export Signed PSBT",
"view_edit_cosigners_title": "Edit Cosigners"
}
}

View File

@ -116,7 +116,7 @@ const PsbtMultisig = () => {
const _renderItemUnsigned = el => {
const renderProvideSignature = el.index === howManySignaturesWeHave();
return (
<View>
<View testID="ItemUnsigned">
<View style={styles.itemUnsignedWrapper}>
<View style={[styles.vaultKeyCircle, stylesHook.vaultKeyCircle]}>
<Text style={[styles.vaultKeyText, stylesHook.vaultKeyText]}>{el.index + 1}</Text>
@ -131,6 +131,7 @@ const PsbtMultisig = () => {
{renderProvideSignature && (
<View>
<TouchableOpacity
testID="ProvideSignature"
style={[styles.provideSignatureButton, stylesHook.provideSignatureButton]}
onPress={() => {
setIsModalVisible(true);
@ -148,7 +149,7 @@ const PsbtMultisig = () => {
const _renderItemSigned = el => {
return (
<View style={styles.flexDirectionRow}>
<View style={styles.flexDirectionRow} testID="ItemSigned">
<View style={[styles.vaultKeyCircleSuccess, stylesHook.vaultKeyCircleSuccess]}>
<Icon size={24} name="check" type="ionicons" color={colors.msSuccessCheck} />
</View>
@ -255,12 +256,17 @@ const PsbtMultisig = () => {
<ScrollView centerContent contentContainerStyle={styles.scrollViewContent}>
<View style={[styles.modalContentShort, stylesHook.modalContentShort]}>
<DynamicQRCode value={psbt.toHex()} capacity={666} />
<BlueSpacing20 />
<SquareButton
style={[styles.exportButton, stylesHook.exportButton]}
onPress={openScanner}
title={loc.multisig.scan_or_import_file}
/>
{!isConfirmEnabled() && (
<>
<BlueSpacing20 />
<SquareButton
testID="CosignedScanOrImportFile"
style={[styles.exportButton, stylesHook.exportButton]}
onPress={openScanner}
title={loc.multisig.scan_or_import_file}
/>
</>
)}
<BlueSpacing20 />
<SquareButton style={[styles.exportButton, stylesHook.exportButton]} onPress={exportPSBT} title={loc.multisig.share} />
<BlueSpacing20 />
@ -328,7 +334,7 @@ const PsbtMultisig = () => {
</BlueText>
<BlueText>{loc.formatString(loc.multisig.fee_btc, { number: currency.satoshiToBTC(getFee()) })}</BlueText>
</View>
<BlueButton disabled={!isConfirmEnabled()} title={loc.multisig.confirm} onPress={onConfirm} />
<BlueButton disabled={!isConfirmEnabled()} title={loc.multisig.confirm} onPress={onConfirm} testID="PsbtMultisigConfirmButton" />
</View>
);
@ -356,6 +362,21 @@ const PsbtMultisig = () => {
ListHeaderComponent={header}
scrollEnabled={false}
/>
{isConfirmEnabled() && (
<View style={styles.height80}>
<TouchableOpacity
testID="ExportSignedPsbt"
style={[styles.provideSignatureButton, stylesHook.provideSignatureButton]}
onPress={() => {
setIsModalVisible(true);
}}
>
<Text style={[styles.provideSignatureButtonText, stylesHook.provideSignatureButtonText]}>
{loc.multisig.export_signed_psbt}
</Text>
</TouchableOpacity>
</View>
)}
</BlueCard>
</View>
</View>
@ -481,6 +502,9 @@ const styles = StyleSheet.create({
textBtcUnit: { justifyContent: 'flex-end', bottom: 8 },
bottomFeesWrapper: { flexDirection: 'row', paddingBottom: 20 },
bottomWrapper: { justifyContent: 'center', alignItems: 'center', paddingVertical: 20 },
height80: {
height: 80,
},
});
PsbtMultisig.navigationOptions = () => ({

View File

@ -550,9 +550,17 @@ describe('BlueWallet UI Tests', () => {
await yo('TransactionValue');
expect(element(by.id('TransactionValue'))).toHaveText('0.0001');
expect(element(by.id('TransactionAddress'))).toHaveText('BC1QH6TF004TY7Z7UN2V5NTU4MKF630545GVHS45U7');
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
it('can import multisig setup from UR (ver1) QRs 2 frames', async () => {
it('can import multisig setup from UR (ver1) QRs (2 frames), and create tx', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', JSON.stringify(jasmine.currentTest.fullName), 'as it previously passed on Travis');
}
await yo('WalletsList');
await element(by.id('WalletsList')).swipe('left', 'fast', 1); // in case emu screen is small and it doesnt fit
// going to Import Wallet screen and importing mnemonic
@ -585,6 +593,87 @@ describe('BlueWallet UI Tests', () => {
// lets go inside wallet
const expectedWalletLabel = 'Multisig Vault';
await element(by.text(expectedWalletLabel)).tap();
// sending...
await element(by.id('SendButton')).tap();
await element(by.id('AddressInput')).replaceText('bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl');
await element(by.id('BitcoinAmountInput')).typeText('0.0005\n');
// setting fee rate:
const feeRate = 1;
await element(by.id('chooseFee')).tap();
await element(by.id('feeCustom')).tap();
await element(by.type('android.widget.EditText')).typeText(feeRate + '');
await element(by.text('OK')).tap();
if (process.env.TRAVIS) await sleep(5000);
try {
await element(by.id('CreateTransactionButton')).tap();
} catch (_) {}
await waitFor(element(by.id('ItemUnsigned'))).toBeVisible();
await waitFor(element(by.id('ItemSigned'))).toBeNotVisible(); // not a single green checkmark
await element(by.id('ProvideSignature')).tap();
await element(by.id('CosignedScanOrImportFile')).tap();
const ursSignedByColdcard = [
'UR:BYTES/1OF3/AZ7UYD5YRTJGJHEPJC045UPYV6SRFURJALR0968WCXHP0ZZ9HK0SV8YW98/TYP6XURNVF607QGQ05PQQQQQQ89FQE9NVDRHTESWDDWCDCAMW53Z2H5U50T6ZRT2JVDQF3Y4QCJESQQQQQQQPLLLLLLSY5XRQQQQQQQQQQTQQ9R75WZLX547D94TPAHFFG8WPC7X6JC555C7U5QQQQQQQQQZYQPQTAH0P50D4QLFTN049K7LLDCWH7CS3ZKJY9G8XEGV63P308HSH9ZSQQQQQQQQZQ82QGQQQQQQQYQUWDNXP9500ELRFUSTVYLPAQJC34GUCHG52MH2665NTY5WSCJS72GPQQQQQQQPQQQGQQJS4YQSQQQQQQQZYQPQY8RVFMEZUPXN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EQV0VELTM4',
'UR:BYTES/3OF3/AZ7UYD5YRTJGJHEPJC045UPYV6SRFURJALR0968WCXHP0ZZ9HK0SV8YW98/WFPVPPLYFLP4RNFHATVGXQQQPQQQQQQGQQQQQZQQYQQQSQQSQQQQQQQQQQPZQGP58TZJMYXW6CMWVYSS9SDMUDESRMG26CXMKUKC7KVG09AAHVC2ARQUZ6XAVQESQQQGQQQQQZQQQQQQSQPQQQYQQYQQQQQQQQQQQQQH8NSKY',
];
for (const ur of ursSignedByColdcard) {
// tapping 10 times invisible button is a backdoor:
for (let c = 0; c <= 10; c++) {
await element(by.id('ScanQrBackdoorButton')).tap();
}
await element(by.id('scanQrBackdoorInput')).replaceText(ur);
await element(by.id('scanQrBackdoorOkButton')).tap();
await waitFor(element(by.id('UrProgressBar'))).toBeVisible();
}
await waitFor(element(by.id('ItemSigned'))).toBeVisible(); // one green checkmark visible
await element(by.id('ProvideSignature')).tap();
await element(by.id('CosignedScanOrImportFile')).tap();
const urSignedByColdcardAndCobo = [
'UR:BYTES/1OF3/CL7WUCY4FVHCWAA0TRRKJ0A5CA3JZTYP2L9PS2ZMPUG59ARUW2US09Z73L/TYP5CURNVF607QGQ05PQQQQQQ89FQE9NVDRHTESWDDWCDCAMW53Z2H5U50T6ZRT2JVDQF3Y4QCJESQQQQQQQPLLLLLLSY5XRQQQQQQQQQQTQQ9R75WZLX547D94TPAHFFG8WPC7X6JC555C7U5QQQQQQQQQZYQPQTAH0P50D4QLFTN049K7LLDCWH7CS3ZKJY9G8XEGV63P308HSH9ZSQQQQQQQQZQ82QGQQQQQQQYQUWDNXP9500ELRFUSTVYLPAQJC34GUCHG52MH2665NTY5WSCJS72GPQQQQQQQPQQQGQQJS4YQSQQQQQQQZYQPQY8RVFMEZUPXNJSKTRUVR389TNY9XLLX7JNYE08K5FJP5R8A2UFN6TYSZQQQQQQQQZCQPFRSXCZANQ56CMLH79RF2KUUEZTAXF7QE6QJ8XPZQYGPSL9CGL7X73GC8MACPM7SNEHE2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7FE',
];
for (const ur of urSignedByColdcardAndCobo) {
// tapping 10 times invisible button is a backdoor:
for (let c = 0; c <= 10; c++) {
await element(by.id('ScanQrBackdoorButton')).tap();
}
await element(by.id('scanQrBackdoorInput')).replaceText(ur);
await element(by.id('scanQrBackdoorOkButton')).tap();
await waitFor(element(by.id('UrProgressBar'))).toBeVisible();
}
await waitFor(element(by.id('ExportSignedPsbt'))).toBeVisible();
await element(by.id('PsbtMultisigConfirmButton')).tap();
// created. verifying:
await yo('TransactionValue');
expect(element(by.id('TransactionValue'))).toHaveText('0.0005');
await element(by.id('TransactionDetailsButton')).tap();
const txhex = await extractTextFromElementById('TxhexInput');
const transaction = bitcoin.Transaction.fromHex(txhex);
assert.ok(transaction.ins.length === 1 || transaction.ins.length === 2); // depending on current fees gona use either 1 or 2 inputs
assert.strictEqual(transaction.outs.length, 2);
assert.strictEqual(bitcoin.address.fromOutputScript(transaction.outs[0].script), 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); // to address
assert.strictEqual(transaction.outs[0].value, 50000);
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
});