|
|
|
@ -15,10 +15,9 @@ describe('Test Snap bip-32', function () { |
|
|
|
|
}; |
|
|
|
|
await withFixtures( |
|
|
|
|
{ |
|
|
|
|
fixtures: new FixtureBuilder() |
|
|
|
|
.withPermissionControllerConnectedToSnapDapp() |
|
|
|
|
.build(), |
|
|
|
|
fixtures: new FixtureBuilder().build(), |
|
|
|
|
ganacheOptions, |
|
|
|
|
failOnConsoleError: false, |
|
|
|
|
title: this.test.title, |
|
|
|
|
}, |
|
|
|
|
async ({ driver }) => { |
|
|
|
@ -32,20 +31,38 @@ describe('Test Snap bip-32', function () { |
|
|
|
|
await driver.driver.get(TEST_SNAPS_WEBSITE_URL); |
|
|
|
|
await driver.delay(1000); |
|
|
|
|
|
|
|
|
|
// find and scroll to the correct card and click first
|
|
|
|
|
const snapButton = await driver.findElement('#sendUpdateHello'); |
|
|
|
|
await driver.scrollToElement(snapButton); |
|
|
|
|
await driver.delay(500); |
|
|
|
|
await driver.fill('#snapId6', 'npm:@metamask/test-snap-bip32'); |
|
|
|
|
// find and scroll to the bip32 test and connect
|
|
|
|
|
const snapButton1 = await driver.findElement('#connectBip32'); |
|
|
|
|
await driver.scrollToElement(snapButton1); |
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#connectBip32'); |
|
|
|
|
|
|
|
|
|
// approve install of snap
|
|
|
|
|
// switch to metamask extension and click connect
|
|
|
|
|
await driver.waitUntilXWindowHandles(2, 5000, 10000); |
|
|
|
|
let windowHandles = await driver.getAllWindowHandles(); |
|
|
|
|
await driver.switchToWindowWithTitle( |
|
|
|
|
'MetaMask Notification', |
|
|
|
|
windowHandles, |
|
|
|
|
); |
|
|
|
|
await driver.clickElement( |
|
|
|
|
{ |
|
|
|
|
text: 'Connect', |
|
|
|
|
tag: 'button', |
|
|
|
|
}, |
|
|
|
|
10000, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
await driver.delay(2000); |
|
|
|
|
|
|
|
|
|
// switch to metamask extension
|
|
|
|
|
await driver.waitUntilXWindowHandles(2, 5000, 10000); |
|
|
|
|
windowHandles = await driver.getAllWindowHandles(); |
|
|
|
|
|
|
|
|
|
// approve install of snap
|
|
|
|
|
await driver.switchToWindowWithTitle( |
|
|
|
|
'MetaMask Notification', |
|
|
|
|
windowHandles, |
|
|
|
|
); |
|
|
|
|
await driver.clickElement({ |
|
|
|
|
text: 'Approve & install', |
|
|
|
|
tag: 'button', |
|
|
|
@ -65,10 +82,46 @@ describe('Test Snap bip-32', function () { |
|
|
|
|
windowHandles = await driver.getAllWindowHandles(); |
|
|
|
|
await driver.switchToWindowWithTitle('Test Snaps', windowHandles); |
|
|
|
|
|
|
|
|
|
// scroll to and click get public key
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const snapButton2 = await driver.findElement('#bip32GetPublic'); |
|
|
|
|
await driver.scrollToElement(snapButton2); |
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#bip32GetPublic'); |
|
|
|
|
|
|
|
|
|
// check for proper public key response
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const retrievePublicKeyResult1 = await driver.findElement( |
|
|
|
|
'#bip32PublicKeyResult', |
|
|
|
|
); |
|
|
|
|
assert.equal( |
|
|
|
|
await retrievePublicKeyResult1.getText(), |
|
|
|
|
'"0x043e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366606ece56791c361a2320e7fad8bcbb130f66d51c591fc39767ab2856e93f8dfb"', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// scroll to and click get compressed public key
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const snapButton3 = await driver.findElement( |
|
|
|
|
'#bip32GetCompressedPublic', |
|
|
|
|
); |
|
|
|
|
await driver.scrollToElement(snapButton3); |
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#bip32GetCompressedPublic'); |
|
|
|
|
|
|
|
|
|
// check for proper public key response
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const retrievePublicKeyResult2 = await driver.findElement( |
|
|
|
|
'#bip32PublicKeyResult', |
|
|
|
|
); |
|
|
|
|
assert.equal( |
|
|
|
|
await retrievePublicKeyResult2.getText(), |
|
|
|
|
'"0x033e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366"', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// wait then run SECP256K1 test
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.fill('#bip32SignMessage', 'foo bar'); |
|
|
|
|
await driver.clickElement('#sendBip32Secp256k1'); |
|
|
|
|
await driver.fill('#bip32Message-secp256k1', 'foo bar'); |
|
|
|
|
await driver.clickElement('#sendBip32-secp256k1'); |
|
|
|
|
|
|
|
|
|
// hit 'approve' on the custom confirm
|
|
|
|
|
await driver.waitUntilXWindowHandles(2, 5000, 10000); |
|
|
|
@ -89,16 +142,23 @@ describe('Test Snap bip-32', function () { |
|
|
|
|
// check result
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const secp256k1Result = await driver.findElement( |
|
|
|
|
'#bip32Secp256k1Result', |
|
|
|
|
'#bip32MessageResult-secp256k1', |
|
|
|
|
); |
|
|
|
|
assert.equal( |
|
|
|
|
await secp256k1Result.getText(), |
|
|
|
|
'Signature: "0xd30561eb9e3195e47d49198fb0bc66eda867a7dff4c5e8b60c2ec13851aa7d8cc3d485da177de63dad331f315d440cbb693a629efe228389c4693ea90465b101"', |
|
|
|
|
'"0x3045022100b3ade2992ea3e5eb58c7550e9bddad356e9554233c8b099ebc3cb418e9301ae2022064746e15ae024808f0ba5d860e44dc4c97e65c8cba6f5ef9ea2e8c819930d2dc"', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// scroll further into messages section
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const snapButton4 = await driver.findElement('#bip32Message-ed25519'); |
|
|
|
|
await driver.scrollToElement(snapButton4); |
|
|
|
|
await driver.delay(1000); |
|
|
|
|
|
|
|
|
|
// wait then run ed25519 test
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#sendBip32Ed25519'); |
|
|
|
|
await driver.fill('#bip32Message-ed25519', 'foo bar'); |
|
|
|
|
await driver.clickElement('#sendBip32-ed25519'); |
|
|
|
|
|
|
|
|
|
// hit 'approve' on the custom confirm
|
|
|
|
|
await driver.waitUntilXWindowHandles(2, 5000, 10000); |
|
|
|
@ -118,38 +178,12 @@ describe('Test Snap bip-32', function () { |
|
|
|
|
|
|
|
|
|
// check result
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const ed25519Result = await driver.findElement('#bip32Ed25519Result'); |
|
|
|
|
assert.equal( |
|
|
|
|
await ed25519Result.getText(), |
|
|
|
|
'Signature: "0xf3215b4d6c59aac7e01b4ceef530d1e2abf4857926b85a81aaae3894505699243768a887b7da4a8c2e0f25196196ba290b6531050db8dc15c252bdd508532a0a"', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const publicKeyButton = await driver.findElement('#sendBip32PublicKey'); |
|
|
|
|
await driver.scrollToElement(publicKeyButton); |
|
|
|
|
// wait then run public key test
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#sendBip32PublicKey'); |
|
|
|
|
// check result
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const publicKeyResult = await driver.findElement( |
|
|
|
|
'#bip32PublicKeyResult', |
|
|
|
|
); |
|
|
|
|
assert.equal( |
|
|
|
|
await publicKeyResult.getText(), |
|
|
|
|
'Public key: "0x043e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366606ece56791c361a2320e7fad8bcbb130f66d51c591fc39767ab2856e93f8dfb"', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// wait then run compressed public key test
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
await driver.clickElement('#sendBip32CompressedPublicKey'); |
|
|
|
|
// check result
|
|
|
|
|
await driver.delay(1000); |
|
|
|
|
const compressedPublicKeyResult = await driver.findElement( |
|
|
|
|
'#bip32CompressedPublicKeyResult', |
|
|
|
|
const ed25519Result = await driver.findElement( |
|
|
|
|
'#bip32MessageResult-ed25519', |
|
|
|
|
); |
|
|
|
|
assert.equal( |
|
|
|
|
await compressedPublicKeyResult.getText(), |
|
|
|
|
'Public key: "0x033e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366"', |
|
|
|
|
await ed25519Result.getText(), |
|
|
|
|
'"0xf3215b4d6c59aac7e01b4ceef530d1e2abf4857926b85a81aaae3894505699243768a887b7da4a8c2e0f25196196ba290b6531050db8dc15c252bdd508532a0a"', |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|