gitlab.com/SiaPrime/SiaPrime@v1.4.1/node/api/explorer_test.go (about)

     1  package api
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gitlab.com/SiaPrime/SiaPrime/types"
     7  )
     8  
     9  // TestIntegrationExplorerGET probes the GET call to /explorer.
    10  func TestIntegrationExplorerGET(t *testing.T) {
    11  	t.Skip("Explorer has deadlock issues")
    12  	if testing.Short() {
    13  		t.SkipNow()
    14  	}
    15  	st, err := createServerTester(t.Name())
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	defer st.server.panicClose()
    20  
    21  	var eg ExplorerGET
    22  	err = st.getAPI("/explorer", &eg)
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	if eg.Height != st.server.api.cs.Height() {
    27  		t.Error("height not accurately reported by explorer")
    28  	}
    29  	if eg.MinerPayoutCount == 0 {
    30  		t.Error("Miner payout count is incorrect")
    31  	}
    32  }
    33  
    34  // TestIntegrationExplorerBlockGET probes the GET call to /explorer/block.
    35  func TestIntegrationExplorerBlockGET(t *testing.T) {
    36  	t.Skip("Explorer has deadlock issues")
    37  	if testing.Short() {
    38  		t.SkipNow()
    39  	}
    40  	st, err := createServerTester(t.Name())
    41  	if err != nil {
    42  		t.Fatal(err)
    43  	}
    44  	defer st.server.panicClose()
    45  
    46  	var ebg ExplorerBlockGET
    47  	err = st.getAPI("/explorer/blocks/0", &ebg)
    48  	if err != nil {
    49  		t.Fatal(err)
    50  	}
    51  	if ebg.Block.BlockID != ebg.Block.RawBlock.ID() {
    52  		t.Error("block id and block do not match up from api call")
    53  	}
    54  	if ebg.Block.BlockID != types.GenesisBlock.ID() {
    55  		t.Error("wrong block returned by /explorer/block?height=0")
    56  	}
    57  }
    58  
    59  // TestIntegrationExplorerHashGet probes the GET call to /explorer/hash/:hash.
    60  func TestIntegrationExplorerHashGet(t *testing.T) {
    61  	t.Skip("Explorer has deadlock issues")
    62  	if testing.Short() {
    63  		t.SkipNow()
    64  	}
    65  	st, err := createServerTester(t.Name())
    66  	if err != nil {
    67  		t.Fatal(err)
    68  	}
    69  	defer st.server.panicClose()
    70  
    71  	var ehg ExplorerHashGET
    72  	gb := types.GenesisBlock
    73  	err = st.getAPI("/explorer/hashes/"+gb.ID().String(), &ehg)
    74  	if err != nil {
    75  		t.Fatal(err)
    76  	}
    77  	if ehg.HashType != "blockid" {
    78  		t.Error("wrong hash type returned when requesting block hash")
    79  	}
    80  	if ehg.Block.BlockID != gb.ID() {
    81  		t.Error("wrong block type returned")
    82  	}
    83  }