-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(web3): Tests for validators.rawTransaction
- Loading branch information
1 parent
06046c3
commit ba52e4c
Showing
1 changed file
with
45 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import test from "ava"; | ||
|
||
import { validators } from "../../src/methods/validator"; | ||
import { InvalidParamsError } from "../../src/methods/error"; | ||
|
||
test("validators.rawTransaction's s with leading zeros", (t) => { | ||
const originRawTx = | ||
"0xf8680485174876e8008302f1c8940000000000000000000000000000000000000000808083022df4a0aa4567c44b378929018ebd3100716f288dd17f616ff9418d7ef0341f3aef4ca0a00013d2f7290ba5aff8911b28871c8e6b624117a711dea4f1484e0dc9d587d60a"; | ||
|
||
const params = [originRawTx]; | ||
|
||
const result = validators.rawTransaction(params, 0); | ||
|
||
t.true(result instanceof InvalidParamsError); | ||
t.is( | ||
result?.message, | ||
"invalid argument 0: rlp: non-canonical integer (leading zero bytes) for s, receive: 0x0013d2f7290ba5aff8911b28871c8e6b624117a711dea4f1484e0dc9d587d60a" | ||
); | ||
}); | ||
|
||
test("validators.rawTranaction's r with leading zeros", (t) => { | ||
const originRawTx = | ||
"0xf8680485174876e8008302f45b940000000000000000000000000000000000000000808083022df4a000330af14634c7d18125258707de6b115ff990743d5c5fac35089e54ea4dfd60a01a9186f9b620063219709aadb6857f88702aa03d94850199c80d39ec090897a2"; | ||
|
||
const params = [originRawTx]; | ||
|
||
const result = validators.rawTransaction(params, 0); | ||
|
||
t.true(result instanceof InvalidParamsError); | ||
t.is( | ||
result?.message, | ||
"invalid argument 0: rlp: non-canonical integer (leading zero bytes) for r, receive: 0x00330af14634c7d18125258707de6b115ff990743d5c5fac35089e54ea4dfd60" | ||
); | ||
}); | ||
|
||
test("validators.rawTransaction valid", (t) => { | ||
const originRawTx = | ||
"0xf8670485174876e8008302f45b940000000000000000000000000000000000000000808083022df49f330af14634c7d18125258707de6b115ff990743d5c5fac35089e54ea4dfd60a01a9186f9b620063219709aadb6857f88702aa03d94850199c80d39ec090897a2"; | ||
|
||
const params = [originRawTx]; | ||
|
||
const result = validators.rawTransaction(params, 0); | ||
|
||
t.is(result, undefined); | ||
}); |