2024-12-02 15:45:44 +01:00
|
|
|
import std/unittest
|
|
|
|
|
import codexvalidator/basics
|
|
|
|
|
import codexvalidator/transaction
|
|
|
|
|
import ./examples
|
|
|
|
|
|
|
|
|
|
suite "Transaction":
|
|
|
|
|
|
|
|
|
|
test "a transaction can contain a storage proof":
|
2024-12-02 16:07:47 +01:00
|
|
|
let requestId = StorageRequestId.example
|
|
|
|
|
let slotIndex = uint32.example
|
2024-12-02 15:45:44 +01:00
|
|
|
let period = Period.example
|
2024-12-02 16:07:47 +01:00
|
|
|
let merkleRoot = UInt256.example
|
|
|
|
|
let challenge = UInt256.example
|
2024-12-02 15:45:44 +01:00
|
|
|
let proof = Groth16Proof.example
|
2024-12-02 16:07:47 +01:00
|
|
|
let transaction = Transaction.storageProof(
|
|
|
|
|
requestId, slotIndex, period, merkleRoot, challenge, proof
|
|
|
|
|
)
|
|
|
|
|
check transaction.requestId == requestId
|
|
|
|
|
check transaction.slotIndex == slotIndex
|
|
|
|
|
check transaction.period == period
|
|
|
|
|
check transaction.merkleRoot == merkleRoot
|
|
|
|
|
check transaction.challenge == challenge
|
2024-12-02 15:45:44 +01:00
|
|
|
check transaction.proof == proof
|
|
|
|
|
|
|
|
|
|
test "a transaction can indicate a missing storage proof":
|
2024-12-02 16:07:47 +01:00
|
|
|
let requestId = StorageRequestId.example
|
|
|
|
|
let slotIndex = uint32.example
|
2024-12-02 15:45:44 +01:00
|
|
|
let period = Period.example
|
2024-12-02 16:07:47 +01:00
|
|
|
let merkleRoot = UInt256.example
|
|
|
|
|
let challenge = UInt256.example
|
|
|
|
|
let transaction = Transaction.missingProof(
|
|
|
|
|
requestId, slotIndex, period, merkleRoot, challenge
|
|
|
|
|
)
|
|
|
|
|
check transaction.requestId == requestId
|
|
|
|
|
check transaction.slotIndex == slotIndex
|
2024-12-02 15:45:44 +01:00
|
|
|
check transaction.period == period
|
2024-12-02 16:07:47 +01:00
|
|
|
check transaction.merkleRoot == merkleRoot
|
|
|
|
|
check transaction.challenge == challenge
|
2024-12-02 15:45:44 +01:00
|
|
|
|
|
|
|
|
test "transactions have a fixed version":
|
|
|
|
|
let transaction = Transaction.example
|
|
|
|
|
check transaction.version == TransactionVersion.version0
|