-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tests for each branching * removed unused import * fix
- Loading branch information
1 parent
09ad0ae
commit 454eda3
Showing
1 changed file
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { | ||
assert, | ||
assertFalse, | ||
assertEquals | ||
} from "https://deno.land/[email protected]/assert/mod.ts"; | ||
import { ethValidationFailed } from "./filter.ts"; | ||
import { Event } from "../deps.ts"; | ||
import { ethValidationFailed, isKakarotTransaction } from "./filter.ts"; | ||
import { Event, Transaction } from "../deps.ts"; | ||
|
||
const event = (data: `0x${string}`[]) => { | ||
return { | ||
|
@@ -71,3 +72,86 @@ Deno.test("ethValidationFailed: incorrect data length", () => { | |
const failed = ethValidationFailed(x); | ||
assertFalse(failed); | ||
}); | ||
|
||
Deno.test("isKakarotTransaction: no calldata", () => { | ||
const transaction: Transaction = { | ||
invokeV1: { | ||
senderAddress: "0x01", | ||
calldata: [] | ||
}, | ||
meta: { | ||
hash: "0x01", | ||
maxFee: "0x01", | ||
nonce: "0x01", | ||
signature: ["0x1", "0x2", "0x3", "0x4", "0x32"], | ||
version: "1", | ||
}, | ||
}; | ||
const failed = isKakarotTransaction(transaction); | ||
assertFalse(failed); | ||
}); | ||
|
||
Deno.test("isKakarotTransaction: no `to` field in calldata", () => { | ||
const starknetTxCalldata: `0x${string}`[] = [ | ||
"0x1" | ||
]; | ||
const transaction: Transaction = { | ||
invokeV1: { | ||
senderAddress: "0x01", | ||
calldata: starknetTxCalldata | ||
}, | ||
meta: { | ||
hash: "0x01", | ||
maxFee: "0x01", | ||
nonce: "0x01", | ||
signature: ["0x1", "0x2", "0x3", "0x4", "0x32"], | ||
version: "1", | ||
}, | ||
}; | ||
const failed = isKakarotTransaction(transaction); | ||
assertFalse(failed); | ||
}); | ||
|
||
Deno.test("isKakarotTransaction: `to` address not matching KAKAROT_ADDRESS", () => { | ||
const starknetTxCalldata: `0x${string}`[] = [ | ||
"0x1", | ||
"0x2", | ||
]; | ||
const transaction: Transaction = { | ||
invokeV1: { | ||
senderAddress: "0x01", | ||
calldata: starknetTxCalldata | ||
}, | ||
meta: { | ||
hash: "0x02", | ||
maxFee: "0x02", | ||
nonce: "0x02", | ||
signature: ["0x2"], | ||
version: "1", | ||
}, | ||
}; | ||
const failed = isKakarotTransaction(transaction); | ||
assertEquals(failed, false); | ||
}); | ||
|
||
Deno.test("isKakarotTransaction: `to` address matching KAKAROT_ADDRESS", () => { | ||
const starknetTxCalldata: `0x${string}`[] = [ | ||
"0x1", | ||
"0x1" | ||
]; | ||
const transaction: Transaction = { | ||
invokeV1: { | ||
senderAddress: "0x01", | ||
calldata: starknetTxCalldata | ||
}, | ||
meta: { | ||
hash: "0x01", | ||
maxFee: "0x01", | ||
nonce: "0x01", | ||
signature: ["0x1", "0x2", "0x3", "0x4", "0x1"], | ||
version: "1", | ||
}, | ||
}; | ||
const success = isKakarotTransaction(transaction); | ||
assertEquals(success, true); | ||
}); |