|
|
@ -6,26 +6,30 @@ describe('PAGE_LOAD', () => { |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
addressHash: '1234', |
|
|
|
addressHash: '1234', |
|
|
|
beyondPageOne: false |
|
|
|
beyondPageOne: false, |
|
|
|
|
|
|
|
pendingTransactionHashes: ['1'] |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
|
|
|
expect(output.pendingTransactionHashes).toEqual(['1']) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('page 2 without filter', () => { |
|
|
|
test('page 2 without filter', () => { |
|
|
|
const state = initialState |
|
|
|
const state = initialState |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
|
|
|
|
addressHash: '1234', |
|
|
|
beyondPageOne: true, |
|
|
|
beyondPageOne: true, |
|
|
|
addressHash: '1234' |
|
|
|
pendingTransactionHashes: ['1'] |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
|
|
|
|
expect(output.filter).toBe(undefined) |
|
|
|
|
|
|
|
expect(output.pendingTransactionHashes).toEqual(['1']) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('page 1 with "to" filter', () => { |
|
|
|
test('page 1 with "to" filter', () => { |
|
|
|
const state = initialState |
|
|
|
const state = initialState |
|
|
@ -38,22 +42,22 @@ describe('PAGE_LOAD', () => { |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
expect(output.beyondPageOne).toBe(false) |
|
|
|
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('page 2 with "to" filter', () => { |
|
|
|
test('page 2 with "to" filter', () => { |
|
|
|
const state = initialState |
|
|
|
const state = initialState |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
type: 'PAGE_LOAD', |
|
|
|
beyondPageOne: true, |
|
|
|
|
|
|
|
addressHash: '1234', |
|
|
|
addressHash: '1234', |
|
|
|
|
|
|
|
beyondPageOne: true, |
|
|
|
filter: 'to' |
|
|
|
filter: 'to' |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.addressHash).toBe('1234') |
|
|
|
expect(output.filter).toBe('to') |
|
|
|
|
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
expect(output.beyondPageOne).toBe(true) |
|
|
|
|
|
|
|
expect(output.filter).toBe('to') |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -65,7 +69,6 @@ test('CHANNEL_DISCONNECTED', () => { |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.channelDisconnected).toBe(true) |
|
|
|
expect(output.channelDisconnected).toBe(true) |
|
|
|
expect(output.batchCountAccumulator).toBe(0) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
test('RECEIVED_UPDATED_BALANCE', () => { |
|
|
|
test('RECEIVED_UPDATED_BALANCE', () => { |
|
|
@ -81,68 +84,19 @@ test('RECEIVED_UPDATED_BALANCE', () => { |
|
|
|
expect(output.balance).toBe('hello world') |
|
|
|
expect(output.balance).toBe('hello world') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe('RECEIVED_NEW_PENDING_TRANSACTION_BATCH', () => { |
|
|
|
describe('RECEIVED_NEW_PENDING_TRANSACTION', () => { |
|
|
|
test('single transaction', () => { |
|
|
|
test('single transaction', () => { |
|
|
|
const state = initialState |
|
|
|
const state = initialState |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHtml: 'test' |
|
|
|
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) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactions).toEqual(['test']) |
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([ |
|
|
|
|
|
|
|
"0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x10", "0x11" |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('single transaction after single transaction', () => { |
|
|
|
test('single transaction after single transaction', () => { |
|
|
@ -150,273 +104,97 @@ describe('RECEIVED_NEW_PENDING_TRANSACTION_BATCH', () => { |
|
|
|
newPendingTransactions: ['test 1'] |
|
|
|
newPendingTransactions: ['test 1'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHash: '0x02', |
|
|
|
transactionHash: '0x02', |
|
|
|
transactionHtml: 'test 2' |
|
|
|
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) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactions).toEqual(['test 1', 'test 2']) |
|
|
|
expect(output.newPendingTransactionHashesBatch.length).toEqual(22) |
|
|
|
expect(output.pendingTransactionHashes.length).toEqual(1) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('after disconnection', () => { |
|
|
|
test('after disconnection', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
channelDisconnected: true |
|
|
|
channelDisconnected: true |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([]) |
|
|
|
expect(output.pendingTransactionHashes).toEqual([]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('on page 2', () => { |
|
|
|
test('on page 2', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
beyondPageOne: true |
|
|
|
beyondPageOne: true |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_PENDING_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactions).toEqual([]) |
|
|
|
expect(output.newPendingTransactionHashesBatch).toEqual([]) |
|
|
|
expect(output.pendingTransactionHashes).toEqual([]) |
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
describe('RECEIVED_NEW_TRANSACTION', () => { |
|
|
|
test('single transaction', () => { |
|
|
|
test('single transaction', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
addressHash: '0x111' |
|
|
|
addressHash: '0x111' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHtml: 'test', |
|
|
|
transactionHtml: 'test' |
|
|
|
fromAddressHash: '0x111' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
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) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.newTransactions).toEqual([{ transactionHtml: 'test' }]) |
|
|
|
expect(output.batchCountAccumulator).toEqual(11) |
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
}) |
|
|
|
}) |
|
|
|
test('single transaction after single transaction', () => { |
|
|
|
test('single transaction after single transaction', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
newTransactions: ['test 1'] |
|
|
|
newTransactions: [{ transactionHtml: 'test 1' }] |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHtml: 'test 2' |
|
|
|
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) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
expect(output.batchCountAccumulator).toEqual(12) |
|
|
|
{ transactionHtml: 'test 1' }, |
|
|
|
}) |
|
|
|
{ transactionHtml: 'test 2' } |
|
|
|
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) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
test('after disconnection', () => { |
|
|
|
test('after disconnection', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
channelDisconnected: true |
|
|
|
channelDisconnected: true |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
test('on page 2', () => { |
|
|
|
test('on page 2', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
@ -425,17 +203,15 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
addressHash: '0x111' |
|
|
|
addressHash: '0x111' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHtml: 'test', |
|
|
|
transactionHtml: 'test' |
|
|
|
fromAddressHash: '0x111' |
|
|
|
} |
|
|
|
}] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.batchCountAccumulator).toEqual(0) |
|
|
|
expect(output.transactionCount).toEqual(1) |
|
|
|
expect(output.transactionCount).toEqual(2) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
test('transaction from current address with "from" filter', () => { |
|
|
|
test('transaction from current address with "from" filter', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
@ -443,15 +219,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
filter: 'from' |
|
|
|
filter: 'from' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
fromAddressHash: '1234', |
|
|
|
fromAddressHash: '1234', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
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', () => { |
|
|
|
test('transaction from current address with "to" filter', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
@ -459,11 +237,11 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
filter: 'to' |
|
|
|
filter: 'to' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
fromAddressHash: '1234', |
|
|
|
fromAddressHash: '1234', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
@ -475,15 +253,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
filter: 'to' |
|
|
|
filter: 'to' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
toAddressHash: '1234', |
|
|
|
toAddressHash: '1234', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
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', () => { |
|
|
|
test('transaction to current address with "from" filter', () => { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
|
const state = Object.assign({}, initialState, { |
|
|
@ -491,11 +271,11 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
filter: 'from' |
|
|
|
filter: 'from' |
|
|
|
}) |
|
|
|
}) |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
toAddressHash: '1234', |
|
|
|
toAddressHash: '1234', |
|
|
|
transactionHtml: 'test' |
|
|
|
transactionHtml: 'test' |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const output = reducer(state, action) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
@ -504,58 +284,17 @@ describe('RECEIVED_NEW_TRANSACTION_BATCH', () => { |
|
|
|
test('single transaction collated from pending', () => { |
|
|
|
test('single transaction collated from pending', () => { |
|
|
|
const state = initialState |
|
|
|
const state = initialState |
|
|
|
const action = { |
|
|
|
const action = { |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION_BATCH', |
|
|
|
type: 'RECEIVED_NEW_TRANSACTION', |
|
|
|
msgs: [{ |
|
|
|
msg: { |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHash: '0x00', |
|
|
|
transactionHtml: 'test' |
|
|
|
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) |
|
|
|
const output = reducer(state, action) |
|
|
|
|
|
|
|
|
|
|
|
expect(output.newTransactions).toEqual([]) |
|
|
|
expect(output.newTransactions).toEqual([ |
|
|
|
|
|
|
|
{ transactionHash: '0x00', transactionHtml: 'test' } |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
expect(output.transactionCount).toEqual(null) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|