github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/api/consensus_test.go (about)

     1  package api
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/NebulousLabs/Sia/types"
     7  )
     8  
     9  // TestIntegrationConsensusGet probes the GET call to /consensus.
    10  func TestIntegrationConsensusGET(t *testing.T) {
    11  	if testing.Short() {
    12  		t.SkipNow()
    13  	}
    14  
    15  	st, err := createServerTester("TestIntegrationConsensusGET")
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	defer st.server.Close()
    20  	var cg ConsensusGET
    21  	err = st.getAPI("/consensus", &cg)
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	if cg.Height != 4 {
    26  		t.Error("wrong height returned in consensus GET call")
    27  	}
    28  	if cg.CurrentBlock != st.server.cs.CurrentBlock().ID() {
    29  		t.Error("wrong block returned in consensus GET call")
    30  	}
    31  	expectedTarget := types.Target{128}
    32  	if cg.Target != expectedTarget {
    33  		t.Error("wrong target returned in consensus GET call")
    34  	}
    35  }