Skip to content

Commit

Permalink
Extended unit tests for FunctionCallAnalyzer.
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
  • Loading branch information
ericleponner committed Jun 13, 2023
1 parent 6f64784 commit dad2065
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/unit/utils/analyzer/FunctionCallAnalyzer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe("FunctionCallAnalyzer.spec.ts", () => {
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.outputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()

// 2) mount
Expand All @@ -63,6 +64,7 @@ describe("FunctionCallAnalyzer.spec.ts", () => {
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.outputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()

// 3) input setup (valid encoding)
Expand All @@ -83,9 +85,10 @@ describe("FunctionCallAnalyzer.spec.ts", () => {
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.outputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()

// 4) input setup (invalid encoding)
// 4) input setup (invalid input encoding)
input.value = "0x618dc65e0000000000000000000000000000000000163b5a70a082310000000000000000000000005fe56763c7633efefe8c2272f19732521a48e300"
output.value = "0x00000000000000000000000000000000000000000000000000003dc604b33217"
contractId.value = "0.0.359"
Expand All @@ -98,10 +101,30 @@ describe("FunctionCallAnalyzer.spec.ts", () => {
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBe("Decoding Error (data out-of-bounds)")
expect(functionCallAnalyzer.outputDecodingStatus.value).toBe("Decoding Error (data out-of-bounds)")
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()

// 5) output setup (invalid output encoding)
input.value = "0x49146bde000000000000000000000000845b706151aed537b1fd81c1ea4ea03920097abd0000000000000000000000000000000000000000000000000000000002e6ae09"
output.value = "0x000000009999999999999999999999999"
contractId.value = "0.0.359"
await flushPromises()
expect(functionCallAnalyzer.functionHash.value).toBe("0x49146bde")
expect(functionCallAnalyzer.signature.value).toBe("associateToken(address,address)")
expect(functionCallAnalyzer.inputs.value).toStrictEqual([
new NameTypeValue("account", "address", "0x845b706151aEd537b1FD81c1Ea4EA03920097ABD"),
new NameTypeValue("token", "address", "0x0000000000000000000000000000000002E6Ae09"),
])
expect(functionCallAnalyzer.outputs.value).toStrictEqual([])
expect(functionCallAnalyzer.errorHash.value).toBeNull()
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.outputDecodingStatus.value).toBe("Decoding Error (hex data is odd-length)")
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()


// 5) unmount
// 6) unmount
functionCallAnalyzer.unmount()
await flushPromises()
expect(functionCallAnalyzer.functionHash.value).toBeNull()
Expand All @@ -112,6 +135,7 @@ describe("FunctionCallAnalyzer.spec.ts", () => {
expect(functionCallAnalyzer.errorSignature.value).toBeNull()
expect(functionCallAnalyzer.errorInputs.value).toStrictEqual([])
expect(functionCallAnalyzer.inputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.outputDecodingStatus.value).toBeNull()
expect(functionCallAnalyzer.errorDecodingStatus.value).toBeNull()

})
Expand Down

0 comments on commit dad2065

Please sign in to comment.