2021-06-30 09:22:28 +00:00
|
|
|
import abc/txstore
|
|
|
|
import ./basics
|
|
|
|
import ./alicebob
|
|
|
|
|
|
|
|
suite "Transaction Store":
|
|
|
|
|
|
|
|
let genesis = Transaction.genesis
|
|
|
|
let transaction = Transaction.example
|
2021-07-05 09:54:45 +00:00
|
|
|
let ack = Ack.example
|
2021-06-30 09:22:28 +00:00
|
|
|
|
|
|
|
test "is initialized with a genesis transaction":
|
|
|
|
let store = TxStore.init(genesis)
|
2021-07-05 14:19:36 +00:00
|
|
|
check store.getTx(genesis.hash) == genesis.some
|
2021-06-30 09:22:28 +00:00
|
|
|
|
|
|
|
test "stores transactions":
|
|
|
|
var store = TxStore.init(genesis)
|
2021-07-05 14:19:36 +00:00
|
|
|
check store.getTx(transaction.hash).isNone
|
2021-06-30 09:22:28 +00:00
|
|
|
store.add(transaction)
|
2021-07-05 14:19:36 +00:00
|
|
|
check store.getTx(transaction.hash) == transaction.some
|
2021-07-05 09:54:45 +00:00
|
|
|
|
|
|
|
test "stores acks":
|
|
|
|
var store = TxStore.init(genesis)
|
2021-07-05 14:19:36 +00:00
|
|
|
check store.getAck(ack.hash).isNone
|
2021-07-05 09:54:45 +00:00
|
|
|
store.add(ack)
|
2021-07-05 14:19:36 +00:00
|
|
|
check store.getAck(ack.hash) == ack.some
|