Skip to content

Commit

Permalink
test: add transaction unmarshal test
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesKimara committed Sep 28, 2021
1 parent 1f17c84 commit 1a80725
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
33 changes: 33 additions & 0 deletions api_transaction_test.go
@@ -0,0 +1,33 @@
package blockfrost_test

import (
"path/filepath"
"testing"

"github.com/blockfrost/blockfrost-go"
)

func TestTransactionContentUnmarshal(t *testing.T) {
want := blockfrost.TransactionContent{
Hash: "1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477",
Block: "356b7d7dbb696ccd12775c016941057a9dc70898d87a63fc752271bb46856940",
BlockHeight: 123456,
Slot: 42000000,
Index: 1,
OutputAmount: []struct {
Quantity string `json:"quantity"`

// The unit of the value
Unit string `json:"unit"`
}{},
Fees: "182485",
Deposit: "0",
Size: 433,
InvalidBefore: "",
InvalidHereafter: "13885913",
UtxoCount: 4,
}
fp := filepath.Join(testdata, "json", "transactions", "transaction.json")
got := blockfrost.TransactionContent{}
testStructGotWant(t, fp, &got, &want)
}
4 changes: 2 additions & 2 deletions api_transactions.go
Expand Up @@ -45,10 +45,10 @@ type TransactionContent struct {
Index int `json:"index"`

// Left (included) endpoint of the timelock validity intervals
InvalidBefore *string `json:"invalid_before"`
InvalidBefore string `json:"invalid_before"`

// Right (excluded) endpoint of the timelock validity intervals
InvalidHereafter *string `json:"invalid_hereafter"`
InvalidHereafter string `json:"invalid_hereafter"`

// Count of the MIR certificates within the transaction
MirCertCount int `json:"mir_cert_count"`
Expand Down
22 changes: 22 additions & 0 deletions testdata/json/transactions/transaction.json
@@ -0,0 +1,22 @@
{
"hash": "1e043f100dce12d107f679685acd2fc0610e10f72a92d412794c9773d11d8477",
"block": "356b7d7dbb696ccd12775c016941057a9dc70898d87a63fc752271bb46856940",
"block_height": 123456,
"slot": 42000000,
"index": 1,
"output_amount": [],
"fees": "182485",
"deposit": "0",
"size": 433,
"invalid_before": null,
"invalid_hereafter": "13885913",
"utxo_count": 4,
"withdrawal_count": 0,
"mir_cert_count": 0,
"delegation_count": 0,
"stake_cert_count": 0,
"pool_update_count": 0,
"pool_retire_count": 0,
"asset_mint_or_burn_count": 0,
"redeemer_count": 0
}

0 comments on commit 1a80725

Please sign in to comment.