mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-08 08:23:06 +00:00
24 lines
820 B
Nim
24 lines
820 B
Nim
import ../basics
|
|
import codexvalidator/signatures
|
|
import codexvalidator/transaction
|
|
import ../examples
|
|
|
|
suite "Transaction signing":
|
|
|
|
test "transactions can be signed":
|
|
let identity = Identity.example
|
|
let transaction = Transaction.example
|
|
let signed = identity.sign(transaction)
|
|
check signed.transaction == transaction
|
|
check signed.signer == identity.identifier
|
|
check signed.signature == identity.sign(transaction.toBytes())
|
|
|
|
test "transaction signature can be verified":
|
|
let identity = Identity.example
|
|
let transaction = Transaction.example
|
|
let signed = identity.sign(transaction)
|
|
check signed.verifySignature()
|
|
let forger = Identity.example.identifier
|
|
let forged = SignedTransaction.init(transaction, forger, signed.signature)
|
|
check not forged.verifySignature()
|