|
|
|
@ -6,26 +6,30 @@ describe('PAGE_LOAD', () => { |
|
|
|
|
const action = { |
|
|
|
|
type: 'PAGE_LOAD', |
|
|
|
|
addressHash: '1234', |
|
|
|
|
beyondPageOne: false |
|
|
|
|
beyondPageOne: false, |
|
|
|
|
pendingTransactionHashes: ['1'] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
expect(output.pendingTransactionHashes).toEqual(['1']) |
|
|
|
|
}) |
|
|
|
|
test('page 2 without filter', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'PAGE_LOAD', |
|
|
|
|
addressHash: '1234', |
|
|
|
|
beyondPageOne: true, |
|
|
|
|
addressHash: '1234' |
|
|
|
|
pendingTransactionHashes: ['1'] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
expect(output.pendingTransactionHashes).toEqual(['1']) |
|
|
|
|
}) |
|
|
|
|
test('page 1 with "to" filter', () => { |
|
|
|
|
const state = initialState |
|
|
|
@ -38,22 +42,22 @@ describe('PAGE_LOAD', () => { |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
}) |
|
|
|
|
test('page 2 with "to" filter', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'PAGE_LOAD', |
|
|
|
|
beyondPageOne: true, |
|
|
|
|
addressHash: '1234', |
|
|
|
|
beyondPageOne: true, |
|
|
|
|
filter: 'to' |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -65,7 +69,6 @@ test('CHANNEL_DISCONNECTED', () => { |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.channelDisconnected).toBe(true) |
|
|
|
|
expect(output.batchCountAccumulator).toBe(0) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
test('RECEIVED_UPDATED_BALANCE', () => { |
|
|
|
@ -81,68 +84,19 @@ test('RECEIVED_UPDATED_BALANCE', () => { |
|
|
|
|
expect(output.balance).toBe('hello world') |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
describe('RECEIVED_NEW_PENDING_TRANSACTION_BATCH', () => { |
|
|
|
|
describe('RECEIVED_NEW_PENDING_TRANSACTION', () => { |
|
|
|
|
test('single transaction', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHash: '0x00', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual(['test']) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
|
}) |
|
|
|
|
test('large batch of transactions', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHash: '0x01', |
|
|
|
|
transactionHtml: 'test 1' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x02', |
|
|
|
|
transactionHtml: 'test 2' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x03', |
|
|
|
|
transactionHtml: 'test 3' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x04', |
|
|
|
|
transactionHtml: 'test 4' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x05', |
|
|
|
|
transactionHtml: 'test 5' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x06', |
|
|
|
|
transactionHtml: 'test 6' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x07', |
|
|
|
|
transactionHtml: 'test 7' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x08', |
|
|
|
|
transactionHtml: 'test 8' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x09', |
|
|
|
|
transactionHtml: 'test 9' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x10', |
|
|
|
|
transactionHtml: 'test 10' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x11', |
|
|
|
|
transactionHtml: 'test 11' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([ |
|
|
|
|
"0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x10", "0x11" |
|
|
|
|
]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
expect(output.newPendingTransactions).toEqual(['test']) |
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
|
}) |
|
|
|
|
test('single transaction after single transaction', () => { |
|
|
|
@ -150,273 +104,97 @@ describe('RECEIVED_NEW_PENDING_TRANSACTION_BATCH', () => { |
|
|
|
|
newPendingTransactions: ['test 1'] |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHash: '0x02', |
|
|
|
|
transactionHtml: 'test 2' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual(['test 1', 'test 2']) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch.length).toEqual(0) |
|
|
|
|
}) |
|
|
|
|
test('single transaction after large batch of transactions', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newPendingTransactionHashesBatch: [ |
|
|
|
|
"0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x10", "0x11" |
|
|
|
|
] |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHash: '0x12', |
|
|
|
|
transactionHtml: 'test 12' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch.length).toEqual(12) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch).toContain('0x12') |
|
|
|
|
}) |
|
|
|
|
test('large batch of transactions after large batch of transactions', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newPendingTransactionHashesBatch: [ |
|
|
|
|
"0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x10", "0x11" |
|
|
|
|
] |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHash: '0x12', |
|
|
|
|
transactionHtml: 'test 12' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x13', |
|
|
|
|
transactionHtml: 'test 13' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x14', |
|
|
|
|
transactionHtml: 'test 14' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x15', |
|
|
|
|
transactionHtml: 'test 15' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x16', |
|
|
|
|
transactionHtml: 'test 16' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x17', |
|
|
|
|
transactionHtml: 'test 17' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x18', |
|
|
|
|
transactionHtml: 'test 18' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x19', |
|
|
|
|
transactionHtml: 'test 19' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x20', |
|
|
|
|
transactionHtml: 'test 20' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x21', |
|
|
|
|
transactionHtml: 'test 21' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x22', |
|
|
|
|
transactionHtml: 'test 22' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch.length).toEqual(22) |
|
|
|
|
expect(output.newPendingTransactions).toEqual(['test 1', 'test 2']) |
|
|
|
|
expect(output.pendingTransactionHashes.length).toEqual(1) |
|
|
|
|
}) |
|
|
|
|
test('after disconnection', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
channelDisconnected: true |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHash: '0x00', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([]) |
|
|
|
|
expect(output.pendingTransactionHashes).toEqual([]) |
|
|
|
|
}) |
|
|
|
|
test('on page 2', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
beyondPageOne: true |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHash: '0x00', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
expect(output.pendingTransactionHashes).toEqual([]) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
describe('RECEIVED_NEW_TRANSACTION', () => { |
|
|
|
|
test('single transaction', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
addressHash: '0x111' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test', |
|
|
|
|
fromAddressHash: '0x111' |
|
|
|
|
}] |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual(['test']) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
expect(output.transactionCount).toEqual(1) |
|
|
|
|
}) |
|
|
|
|
test('large batch of transactions', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test 1' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 2' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 3' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 4' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 5' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 6' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 7' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 8' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 9' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 10' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 11' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(11) |
|
|
|
|
expect(output.newTransactions).toEqual([{ transactionHtml: 'test' }]) |
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
|
}) |
|
|
|
|
test('single transaction after single transaction', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newTransactions: ['test 1'] |
|
|
|
|
newTransactions: [{ transactionHtml: 'test 1' }] |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHtml: 'test 2' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual(['test 1', 'test 2']) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
}) |
|
|
|
|
test('single transaction after large batch of transactions', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newTransactions: [], |
|
|
|
|
batchCountAccumulator: 11 |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test 12' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(12) |
|
|
|
|
}) |
|
|
|
|
test('large batch of transactions after large batch of transactions', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newTransactions: [], |
|
|
|
|
batchCountAccumulator: 11 |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test 12' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 13' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 14' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 15' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 16' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 17' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 18' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 19' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 20' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 21' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 22' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(22) |
|
|
|
|
}) |
|
|
|
|
test('increments the transactions count only when the address sent transactions', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
newTransactions: [], |
|
|
|
|
addressHash: '0x111', |
|
|
|
|
transactionCount: 1 |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test 12', |
|
|
|
|
fromAddressHash: '0x111', |
|
|
|
|
toAddressHash: '0x222' |
|
|
|
|
},{ |
|
|
|
|
transactionHtml: 'test 13', |
|
|
|
|
fromAddressHash: '0x222', |
|
|
|
|
toAddressHash: '0x111' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.transactionCount).toEqual(2) |
|
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
|
{ transactionHtml: 'test 1' }, |
|
|
|
|
{ transactionHtml: 'test 2' } |
|
|
|
|
]) |
|
|
|
|
}) |
|
|
|
|
test('after disconnection', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
|
channelDisconnected: true |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
}) |
|
|
|
|
test('on page 2', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
@ -425,17 +203,15 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
addressHash: '0x111' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHtml: 'test', |
|
|
|
|
fromAddressHash: '0x111' |
|
|
|
|
}] |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
expect(output.transactionCount).toEqual(2) |
|
|
|
|
expect(output.transactionCount).toEqual(1) |
|
|
|
|
}) |
|
|
|
|
test('transaction from current address with "from" filter', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
@ -443,15 +219,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
filter: 'from' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
fromAddressHash: '1234', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual(['test']) |
|
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
|
{ fromAddressHash: '1234', transactionHtml: 'test' } |
|
|
|
|
]) |
|
|
|
|
}) |
|
|
|
|
test('transaction from current address with "to" filter', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
@ -459,11 +237,11 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
filter: 'to' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
fromAddressHash: '1234', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
@ -475,15 +253,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
filter: 'to' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
toAddressHash: '1234', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual(['test']) |
|
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
|
{ toAddressHash: '1234', transactionHtml: 'test' } |
|
|
|
|
]) |
|
|
|
|
}) |
|
|
|
|
test('transaction to current address with "from" filter', () => { |
|
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
@ -491,11 +271,11 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
filter: 'from' |
|
|
|
|
}) |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
toAddressHash: '1234', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
@ -504,58 +284,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
|
test('single transaction collated from pending', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
|
msg: { |
|
|
|
|
transactionHash: '0x00', |
|
|
|
|
transactionHtml: 'test' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual(['test']) |
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
}) |
|
|
|
|
test('large batch of transactions', () => { |
|
|
|
|
const state = initialState |
|
|
|
|
const action = { |
|
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
|
msgs: [{ |
|
|
|
|
transactionHash: '0x01', |
|
|
|
|
transactionHtml: 'test 1' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x02', |
|
|
|
|
transactionHtml: 'test 2' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x03', |
|
|
|
|
transactionHtml: 'test 3' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x04', |
|
|
|
|
transactionHtml: 'test 4' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x05', |
|
|
|
|
transactionHtml: 'test 5' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x06', |
|
|
|
|
transactionHtml: 'test 6' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x07', |
|
|
|
|
transactionHtml: 'test 7' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x08', |
|
|
|
|
transactionHtml: 'test 8' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x09', |
|
|
|
|
transactionHtml: 'test 9' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x10', |
|
|
|
|
transactionHtml: 'test 10' |
|
|
|
|
},{ |
|
|
|
|
transactionHash: '0x11', |
|
|
|
|
transactionHtml: 'test 11' |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
|
{ transactionHash: '0x00', transactionHtml: 'test' } |
|
|
|
|
]) |
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|