mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
fix tx tests
This commit is contained in:
parent
61a279204a
commit
b77cc3d969
@ -289,10 +289,10 @@ class TransactionController extends EventEmitter {
|
|||||||
// sign tx
|
// sign tx
|
||||||
const fromAddress = txParams.from
|
const fromAddress = txParams.from
|
||||||
const ethTx = new Transaction(txParams)
|
const ethTx = new Transaction(txParams)
|
||||||
const signedTx = await this.signEthTx(ethTx, fromAddress)
|
await this.signEthTx(ethTx, fromAddress)
|
||||||
// set state to signed
|
// set state to signed
|
||||||
this.txStateManager.setTxStatusSigned(txMeta.id)
|
this.txStateManager.setTxStatusSigned(txMeta.id)
|
||||||
const rawTx = ethUtil.bufferToHex(signedTx.serialize())
|
const rawTx = ethUtil.bufferToHex(ethTx.serialize())
|
||||||
return rawTx
|
return rawTx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,14 +549,14 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
keyringName = LedgerBridgeKeyring.type
|
keyringName = LedgerBridgeKeyring.type
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error('MetamaskController:connectHardware - Unknown device')
|
throw new Error('MetamaskController:getKeyringForDevice - Unknown device')
|
||||||
}
|
}
|
||||||
let keyring = await this.keyringController.getKeyringsByType(keyringName)[0]
|
let keyring = await this.keyringController.getKeyringsByType(keyringName)[0]
|
||||||
if (!keyring) {
|
if (!keyring) {
|
||||||
keyring = await this.keyringController.addNewKeyring(keyringName)
|
keyring = await this.keyringController.addNewKeyring(keyringName)
|
||||||
}
|
}
|
||||||
if (hdPath) {
|
if (hdPath && keyring.setHdPath) {
|
||||||
keyring.hdPath = hdPath
|
keyring.setHdPath(hdPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
keyring.network = this.networkController.getProviderConfig().type
|
keyring.network = this.networkController.getProviderConfig().type
|
||||||
|
@ -226,9 +226,9 @@ describe('MetaMaskController', function () {
|
|||||||
|
|
||||||
it('should throw if it receives an unknown device name', async function () {
|
it('should throw if it receives an unknown device name', async function () {
|
||||||
try {
|
try {
|
||||||
await metamaskController.connectHardware('Some random device name', 0)
|
await metamaskController.connectHardware('Some random device name', 0, `m/44/0'/0'`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.equal(e, 'Error: MetamaskController:connectHardware - Unknown device')
|
assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -242,14 +242,24 @@ describe('MetaMaskController', function () {
|
|||||||
assert.equal(keyrings.length, 1)
|
assert.equal(keyrings.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should add the Ledger Hardware keyring', async function () {
|
||||||
|
sinon.spy(metamaskController.keyringController, 'addNewKeyring')
|
||||||
|
await metamaskController.connectHardware('ledger', 0).catch((e) => null)
|
||||||
|
const keyrings = await metamaskController.keyringController.getKeyringsByType(
|
||||||
|
'Ledger Hardware'
|
||||||
|
)
|
||||||
|
assert.equal(metamaskController.keyringController.addNewKeyring.getCall(0).args, 'Ledger Hardware')
|
||||||
|
assert.equal(keyrings.length, 1)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('checkHardwareStatus', function () {
|
describe('checkHardwareStatus', function () {
|
||||||
it('should throw if it receives an unknown device name', async function () {
|
it('should throw if it receives an unknown device name', async function () {
|
||||||
try {
|
try {
|
||||||
await metamaskController.checkHardwareStatus('Some random device name')
|
await metamaskController.checkHardwareStatus('Some random device name', `m/44/0'/0'`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.equal(e, 'Error: MetamaskController:checkHardwareStatus - Unknown device')
|
assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -265,7 +275,7 @@ describe('MetaMaskController', function () {
|
|||||||
try {
|
try {
|
||||||
await metamaskController.forgetDevice('Some random device name')
|
await metamaskController.forgetDevice('Some random device name')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.equal(e, 'Error: MetamaskController:forgetDevice - Unknown device')
|
assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -282,7 +292,7 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('unlockTrezorAccount', function () {
|
describe('unlockHardwareWalletAccount', function () {
|
||||||
let accountToUnlock
|
let accountToUnlock
|
||||||
let windowOpenStub
|
let windowOpenStub
|
||||||
let addNewAccountStub
|
let addNewAccountStub
|
||||||
@ -305,8 +315,8 @@ describe('MetaMaskController', function () {
|
|||||||
sinon.spy(metamaskController.preferencesController, 'setAddresses')
|
sinon.spy(metamaskController.preferencesController, 'setAddresses')
|
||||||
sinon.spy(metamaskController.preferencesController, 'setSelectedAddress')
|
sinon.spy(metamaskController.preferencesController, 'setSelectedAddress')
|
||||||
sinon.spy(metamaskController.preferencesController, 'setAccountLabel')
|
sinon.spy(metamaskController.preferencesController, 'setAccountLabel')
|
||||||
await metamaskController.connectHardware('trezor', 0).catch((e) => null)
|
await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`)
|
||||||
await metamaskController.unlockTrezorAccount(accountToUnlock).catch((e) => null)
|
await metamaskController.unlockHardwareWalletAccount('trezor', accountToUnlock, `m/44/0'/0'`)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -23,7 +23,8 @@ class AccountList extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToNextPage = () => {
|
goToNextPage = () => {
|
||||||
if (this.props.accounts === 5) {
|
// If we have < 5 accounts, it's restricted by BIP-44
|
||||||
|
if (this.props.accounts.length === 5) {
|
||||||
this.props.getPage(this.props.device, 1, this.props.selectedPath)
|
this.props.getPage(this.props.device, 1, this.props.selectedPath)
|
||||||
} else {
|
} else {
|
||||||
this.props.onAccountRestriction()
|
this.props.onAccountRestriction()
|
||||||
|
Loading…
Reference in New Issue
Block a user