Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions apps/remix-ide-e2e/src/tests/terminal.test.ts

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion libs/remix-lib/src/execution/logsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ export class LogsManager {
}

eventMatchesFilter (changeEvent, queryType, queryFilter) {
if (queryFilter.topics.filter((logTopic) => changeEvent.log.topics.indexOf(logTopic) >= 0).length === 0) return false
// topics should match
let noMatch = false
for (let i = 0; i < queryFilter.topics.length; i++) {
if (!queryFilter.topics[i]) {
continue // if the topic isn't defined, we consider it a match.
}
if (Array.isArray(queryFilter.topics[i])) {
if (queryFilter.topics[i].indexOf(changeEvent.log.topics[i]) === -1) {
noMatch = true
}
continue
}
if (queryFilter.topics[i] !== changeEvent.log.topics[i]) noMatch = true
}
if (noMatch) return false

if (queryType === 'logs') {
const fromBlock = parseInt(queryFilter.fromBlock || '0x0')
Expand Down
17 changes: 13 additions & 4 deletions libs/remix-simulator/test/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ describe('Events', () => {
address: receiptTest.contractAddress,
fromBlock: 3,
toBlock: 'latest',
topics: ['0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc', '0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
topics: ['0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
})

let ownerLogs = await web3.eth.getPastLogs({
address: receiptOwner.contractAddress,
fromBlock: 3,
toBlock: 'latest',
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})

// this should include the event triggered by the "set" transaction call.
Expand All @@ -56,7 +56,7 @@ describe('Events', () => {
address: receiptOwner.contractAddress,
fromBlock: 2,
toBlock: 'latest',
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})
// this should include the event triggered from the ctor.
assert.equal(ownerLogs.length, 2, '3) ownerLogs length should be equal to 2')
Expand All @@ -65,10 +65,19 @@ describe('Events', () => {
address: receiptOwner.contractAddress,
fromBlock: 1,
toBlock: 2,
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']
topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735']
})
// this should only include the event triggered from the ctor.
assert.equal(ownerLogs.length, 1, '4) ownerLogs length should be equal to 1')

ownerLogs = await web3.eth.getPastLogs({
address: receiptOwner.contractAddress,
fromBlock: 1,
toBlock: 2,
topics: [['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc']]
})
// 0xdcd9c7fa0342f01013b is a topic from a event emitted by the other contract and should not be take into account.
assert.equal(ownerLogs.length, 1, '5) ownerLogs length should be equal to 1')
})
})
})
Expand Down
Loading