Run prettier (yarn format)

This commit is contained in:
Elliot Lee
2020-04-27 12:06:18 -07:00
parent c26ddb497e
commit 547b63b891
8 changed files with 201 additions and 99 deletions

View File

@@ -1,7 +1,7 @@
import assert from 'assert-diff'
import responses from '../../fixtures/responses'
import {TestSuite} from '../../utils'
import { GenerateAddressOptions } from '../../../src/offline/generate-address'
import {GenerateAddressOptions} from '../../../src/offline/generate-address'
/**
* Every test suite exports their tests in the default object.
@@ -9,7 +9,7 @@ import { GenerateAddressOptions } from '../../../src/offline/generate-address'
* - Check out "test/api/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'generateXAddress': async (api) => {
'generateXAddress': async api => {
// GIVEN entropy of all zeros
function random() {
return new Array(16).fill(0)
@@ -24,7 +24,7 @@ export default <TestSuite>{
)
},
'generateXAddress invalid entropy': async (api) => {
'generateXAddress invalid entropy': async api => {
assert.throws(() => {
// GIVEN entropy of 1 byte
function random() {
@@ -39,18 +39,21 @@ export default <TestSuite>{
}, api.errors.UnexpectedError)
},
'generateXAddress with no options object': async (api) => {
'generateXAddress with no options object': async api => {
// GIVEN no options
// WHEN generating an X-address
const account = api.generateXAddress()
// THEN we get an object with an xAddress starting with 'X' and a secret starting with 's'
assert(account.xAddress.startsWith('X'), 'By default X-addresses start with X')
assert(
account.xAddress.startsWith('X'),
'By default X-addresses start with X'
)
assert(account.secret.startsWith('s'), 'Secrets start with s')
},
'generateXAddress with empty options object': async (api) => {
'generateXAddress with empty options object': async api => {
// GIVEN an empty options object
const options = {}
@@ -58,11 +61,14 @@ export default <TestSuite>{
const account = api.generateXAddress(options)
// THEN we get an object with an xAddress starting with 'X' and a secret starting with 's'
assert(account.xAddress.startsWith('X'), 'By default X-addresses start with X')
assert(
account.xAddress.startsWith('X'),
'By default X-addresses start with X'
)
assert(account.secret.startsWith('s'), 'Secrets start with s')
},
'generateXAddress with algorithm `ecdsa-secp256k1`': async (api) => {
'generateXAddress with algorithm `ecdsa-secp256k1`': async api => {
// GIVEN we want to use 'ecdsa-secp256k1'
const options: GenerateAddressOptions = {algorithm: 'ecdsa-secp256k1'}
@@ -70,12 +76,23 @@ export default <TestSuite>{
const account = api.generateXAddress(options)
// THEN we get an object with an xAddress starting with 'X' and a secret starting with 's'
assert(account.xAddress.startsWith('X'), 'By default X-addresses start with X')
assert.deepEqual(account.secret.slice(0, 1), 's', `Secret ${account.secret} must start with 's'`)
assert.notStrictEqual(account.secret.slice(0, 3), 'sEd', `secp256k1 secret ${account.secret} must not start with 'sEd'`)
assert(
account.xAddress.startsWith('X'),
'By default X-addresses start with X'
)
assert.deepEqual(
account.secret.slice(0, 1),
's',
`Secret ${account.secret} must start with 's'`
)
assert.notStrictEqual(
account.secret.slice(0, 3),
'sEd',
`secp256k1 secret ${account.secret} must not start with 'sEd'`
)
},
'generateXAddress with algorithm `ed25519`': async (api) => {
'generateXAddress with algorithm `ed25519`': async api => {
// GIVEN we want to use 'ed25519'
const options: GenerateAddressOptions = {algorithm: 'ed25519'}
@@ -83,13 +100,23 @@ export default <TestSuite>{
const account = api.generateXAddress(options)
// THEN we get an object with an xAddress starting with 'X' and a secret starting with 'sEd'
assert(account.xAddress.startsWith('X'), 'By default X-addresses start with X')
assert.deepEqual(account.secret.slice(0, 3), 'sEd', `Ed25519 secret ${account.secret} must start with 'sEd'`)
assert(
account.xAddress.startsWith('X'),
'By default X-addresses start with X'
)
assert.deepEqual(
account.secret.slice(0, 3),
'sEd',
`Ed25519 secret ${account.secret} must start with 'sEd'`
)
},
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy': async (api) => {
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy': async api => {
// GIVEN we want to use 'ecdsa-secp256k1' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ecdsa-secp256k1', entropy: new Array(16).fill(0)}
const options: GenerateAddressOptions = {
algorithm: 'ecdsa-secp256k1',
entropy: new Array(16).fill(0)
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -98,9 +125,12 @@ export default <TestSuite>{
assert.deepEqual(account, responses.generateXAddress)
},
'generateXAddress with algorithm `ed25519` and given entropy': async (api) => {
'generateXAddress with algorithm `ed25519` and given entropy': async api => {
// GIVEN we want to use 'ed25519' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ed25519', entropy: new Array(16).fill(0)}
const options: GenerateAddressOptions = {
algorithm: 'ed25519',
entropy: new Array(16).fill(0)
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -112,9 +142,13 @@ export default <TestSuite>{
})
},
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy; include classic address': async (api) => {
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy; include classic address': async api => {
// GIVEN we want to use 'ecdsa-secp256k1' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ecdsa-secp256k1', entropy: new Array(16).fill(0), includeClassicAddress: true}
const options: GenerateAddressOptions = {
algorithm: 'ecdsa-secp256k1',
entropy: new Array(16).fill(0),
includeClassicAddress: true
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -123,9 +157,13 @@ export default <TestSuite>{
assert.deepEqual(account, responses.generateAddress)
},
'generateXAddress with algorithm `ed25519` and given entropy; include classic address': async (api) => {
'generateXAddress with algorithm `ed25519` and given entropy; include classic address': async api => {
// GIVEN we want to use 'ed25519' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ed25519', entropy: new Array(16).fill(0), includeClassicAddress: true}
const options: GenerateAddressOptions = {
algorithm: 'ed25519',
entropy: new Array(16).fill(0),
includeClassicAddress: true
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -134,14 +172,19 @@ export default <TestSuite>{
assert.deepEqual(account, {
xAddress: 'X7xq1YJ4xmLSGGLhuakFQB9CebWYthQkgsvFC4LGFH871HB',
secret: 'sEdSJHS4oiAdz7w2X2ni1gFiqtbJHqE',
classicAddress: "r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7",
address: "r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7"
classicAddress: 'r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7',
address: 'r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7'
})
},
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy; include classic address; for test network use': async (api) => {
'generateXAddress with algorithm `ecdsa-secp256k1` and given entropy; include classic address; for test network use': async api => {
// GIVEN we want to use 'ecdsa-secp256k1' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ecdsa-secp256k1', entropy: new Array(16).fill(0), includeClassicAddress: true, test: true}
const options: GenerateAddressOptions = {
algorithm: 'ecdsa-secp256k1',
entropy: new Array(16).fill(0),
includeClassicAddress: true,
test: true
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -153,9 +196,14 @@ export default <TestSuite>{
assert.deepEqual(account, response)
},
'generateXAddress with algorithm `ed25519` and given entropy; include classic address; for test network use': async (api) => {
'generateXAddress with algorithm `ed25519` and given entropy; include classic address; for test network use': async api => {
// GIVEN we want to use 'ed25519' with entropy of zero
const options: GenerateAddressOptions = {algorithm: 'ed25519', entropy: new Array(16).fill(0), includeClassicAddress: true, test: true}
const options: GenerateAddressOptions = {
algorithm: 'ed25519',
entropy: new Array(16).fill(0),
includeClassicAddress: true,
test: true
}
// WHEN generating an X-address
const account = api.generateXAddress(options)
@@ -164,12 +212,12 @@ export default <TestSuite>{
assert.deepEqual(account, {
xAddress: 'T7t4HeTMF5tT68agwuVbJwu23ssMPeh8dDtGysZoQiij1oo',
secret: 'sEdSJHS4oiAdz7w2X2ni1gFiqtbJHqE',
classicAddress: "r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7",
address: "r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7"
classicAddress: 'r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7',
address: 'r9zRhGr7b6xPekLvT6wP4qNdWMryaumZS7'
})
},
'generateXAddress for test network use': async (api) => {
'generateXAddress for test network use': async api => {
// GIVEN we want an X-address for test network use
const options: GenerateAddressOptions = {test: true}
@@ -177,7 +225,15 @@ export default <TestSuite>{
const account = api.generateXAddress(options)
// THEN we get an object with xAddress starting with 'T' and a secret starting with 's'
assert.deepEqual(account.xAddress.slice(0, 1), 'T', 'Test X-addresses start with T')
assert.deepEqual(account.secret.slice(0, 1), 's', `Secret ${account.secret} must start with 's'`)
assert.deepEqual(
account.xAddress.slice(0, 1),
'T',
'Test X-addresses start with T'
)
assert.deepEqual(
account.secret.slice(0, 1),
's',
`Secret ${account.secret} must start with 's'`
)
}
}