Skip to content

Commit

Permalink
fix: update second signature tests (#1665)
Browse files Browse the repository at this point in the history
  • Loading branch information
spkjp authored and faustbrian committed Dec 6, 2018
1 parent fb6b917 commit 662c59f
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 178 deletions.
9 changes: 4 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ jobs:
./node_modules/.bin/cross-env ARK_ENV=test ./node_modules/.bin/jest
./packages/core-vote-report/ ./packages/core-transaction-pool/
./packages/core-snapshots-cli/ ./packages/core-logger-winston/
./packages/core-api/ ./packages/core-event-emitter/
./packages/core-http-utils/ ./packages/core-event-emitter/
./packages/core-elasticsearch/ ./packages/core-database-postgres/
./packages/core-config/ ./packages/core-http-utils/
--detectOpenHandles --runInBand --forceExit --ci --coverage | tee
test_output.txt
./packages/core-config/ ./packages/core/ --detectOpenHandles
--runInBand --forceExit --ci --coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
when: on_fail
Expand Down Expand Up @@ -158,7 +157,7 @@ jobs:
./packages/core-test-utils/ ./packages/core-p2p/
./packages/core-json-rpc/ ./packages/core-forger/
./packages/core-error-tracker-bugsnag/ ./packages/core-debugger-cli/
./packages/core-container/ ./packages/core/ --detectOpenHandles
./packages/core-container/ ./packages/core-api/ --detectOpenHandles
--runInBand --forceExit --ci --coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
Expand Down
153 changes: 51 additions & 102 deletions packages/core-api/__tests__/v2/handlers/transactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ describe('API 2.0 - Transactions', () => {

expect(response.data.data).toHaveLength(1)

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
}
})
})

Expand Down Expand Up @@ -186,13 +187,12 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

expect(response.data.data).toHaveLength(51)

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
expect(transaction.type).toBe(type)
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.type).toBe(type)
}
})
})

Expand All @@ -206,13 +206,13 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

expect(response.data.data).toHaveLength(100)
expect(response.data.meta.totalCount).toBe(153)

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.version).toBe(version)
}
})
})

Expand All @@ -227,16 +227,10 @@ describe('API 2.0 - Transactions', () => {

expect(response).toBeSuccessfulResponse()

const data = response.data.data
expect(data).toBeArray()

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.sender).toBe(senderAddress)
}
})
})

Expand All @@ -251,16 +245,10 @@ describe('API 2.0 - Transactions', () => {

expect(response).toBeSuccessfulResponse()

const data = response.data.data
expect(data).toBeArray()

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.sender).toBe(senderAddress)
}
})
})

Expand All @@ -274,12 +262,12 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

expect(response.data.data).toHaveLength(2)

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.recipient).toBe(recipientAddress)
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.recipient).toBe(recipientAddress)
}
})
})

Expand All @@ -301,17 +289,10 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data.length).toEqual(100)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.timestamp.epoch).toBe(timestamp)
}
})
})

Expand All @@ -333,17 +314,13 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data).toHaveLength(100)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.timestamp.epoch).toBeGreaterThanOrEqual(
timestampFrom,
)
expect(transaction.timestamp.epoch).toBeLessThanOrEqual(timestampTo)
}
})
})

Expand All @@ -365,17 +342,10 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data).toHaveLength(50)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.amount).toBe(amount)
}
})
})

Expand All @@ -397,17 +367,11 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data).toHaveLength(50)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.amount).toBeGreaterThanOrEqual(amountFrom)
expect(transaction.amount).toBeLessThanOrEqual(amountTo)
}
})
})

Expand All @@ -429,17 +393,10 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data).toHaveLength(100)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.fee).toBe(fee)
}
})
})

Expand All @@ -461,17 +418,11 @@ describe('API 2.0 - Transactions', () => {
expect(data).toBeArray()
expect(data).toHaveLength(100)

data.forEach(transaction => {
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
})

const transactions = {}
genesisBlock.transactions.forEach(transaction => {
transactions[transaction.id] = true
})
const failed = data.some(transaction => !transactions[transaction.id])

expect(!failed).toBeTrue()
expect(transaction.fee).toBeGreaterThanOrEqual(feeFrom)
expect(transaction.fee).toBeLessThanOrEqual(feeTo)
}
})
})

Expand All @@ -492,12 +443,12 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

expect(response.data.data).toHaveLength(1)

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
for (const transaction of response.data.data) {
utils.expectTransaction(transaction)
expect(transaction.vendorField).toBe(vendorFieldHex.toString('utf8'))
}
})
})

Expand All @@ -512,7 +463,6 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

expect(response.data.data).toHaveLength(0)
})
})
Expand All @@ -532,7 +482,6 @@ describe('API 2.0 - Transactions', () => {
})
expect(response).toBeSuccessfulResponse()
expect(response.data.data).toBeArray()

utils.expectTransaction(response.data.data[0])
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = model => {
return {
id: data.id,
blockId: model.blockId,
version: data.version,
type: data.type,
amount: +bignumify(data.amount).toFixed(),
fee: +bignumify(data.fee).toFixed(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ exports.dummy2 = new Transaction({
recipientId: 'DFyDKsyvR4x9D9zrfEaPmeJxSniT5N5qY8',
signature:
'3045022100ead721ae139c0a18a7be2077453337f8305e02a474a3e4e35eb22bcf59ce474c02207ea591ac68b5cfee068ac605efb000c7e1e7479abc7f6ee7ece21f3a5c629800',
secondSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
signSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
id: 'e665f6634fdbbbc562f79b92c8f0acd621081680c247cb4a6fc987bf456ea554',
})

Expand Down Expand Up @@ -165,10 +161,6 @@ exports.dummy10 = new Transaction({
recipientId: 'DFyDKsyvR4x9D9zrfEaPmeJxSniT5N5qY8',
signature:
'3045022100ead721ae139c0a18a7be2077453337f8305e02a474a3e4e35eb22bcf59ce474c02207ea591ac68b5cfee068ac605efb000c7e1e7479abc7f6ee7ece21f3a5c629800',
secondSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
signSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
vendorField: 'Expiring transaction 2',
})

Expand Down Expand Up @@ -202,9 +194,5 @@ exports.dummyExp2 = new Transaction({
recipientId: 'DFyDKsyvR4x9D9zrfEaPmeJxSniT5N5qY8',
signature:
'3045022100ead721ae139c0a18a7be2077453337f8305e02a474a3e4e35eb22bcf59ce474c02207ea591ac68b5cfee068ac605efb000c7e1e7479abc7f6ee7ece21f3a5c629800',
secondSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
signSignature:
'3044022006bd359a6820353e5e2f28adc0569f79ee7ed2918ee169bb149ca582f613fa760220502f39db1f9568edeb05df08d570a21a8204cb66f993f7cea6554a3298c548be',
vendorField: 'Expiring transaction 2',
})
Loading

0 comments on commit 662c59f

Please sign in to comment.