forked from centrifuge/go-substrate-rpc-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Types for storage, blocks and headers for M2 (#23)
* Adds AccountId, AccountIndex and AccountInfo types * Add Data type * Fix linting errors * Implement Moment type * Implements Null type * Change codec to make it accept any value that can be cast to a string * Implement Text type * Implement Origin and Weight types * Implement WeightMultiplier type * Fix linting errors * Improve Data and StorageDataRaw types not to require any length information for decoding. * Implement GetKeys * Implement GetStorageSize * Implement GetStorageHash * Implement GetFinalizedHead * Implement Header and Signature types * Implement GetHeader * Implement GetBlock * Fix linting errors
- Loading branch information
1 parent
81fc3c4
commit d2702f6
Showing
38 changed files
with
1,146 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*types.SignedBlock(&types.SignedBlock{Block:types.Block{Header:types.Header{ParentHash:types.Hash{0xc1, 0x75, 0x51, 0x36, 0x74, 0x91, 0xbf, 0x6d, 0x10, 0xe8, 0xe7, 0x74, 0x84, 0x8b, 0x1b, 0x5c, 0xbb, 0xb2, 0x89, 0x56, 0xb8, 0x47, 0x88, 0xa8, 0xbf, 0x6c, 0x3, 0x38, 0x5f, 0xa2, 0x96, 0x3e}, Number:0x0, StateRoot:types.Hash{0x9d, 0xfb, 0x54, 0xaa, 0x59, 0x7f, 0x1f, 0xec, 0xa4, 0x50, 0x54, 0xcb, 0xfe, 0x9, 0xfc, 0xe1, 0x76, 0x23, 0x2a, 0xe3, 0x38, 0xd6, 0xc, 0x1f, 0xcd, 0x94, 0xf3, 0xe0, 0xd5, 0x15, 0x73, 0xf9}, ExtrinsicsRoot:types.Hash{0xe3, 0x6f, 0xae, 0x7b, 0x50, 0xc6, 0x3a, 0x73, 0x8c, 0x38, 0x7, 0xa8, 0x38, 0xa, 0x38, 0x83, 0x83, 0xaa, 0xfa, 0x5c, 0x37, 0x1d, 0xef, 0x5b, 0x85, 0x54, 0xba, 0xce, 0x15, 0x96, 0x90, 0x98}, Digest:types.Digest{types.DigestItem{IsOther:false, AsOther:types.Bytes(nil), IsAuthoritiesChange:false, AsAuthoritiesChange:[]types.AuthorityID(nil), IsChangesTrieRoot:false, AsChangesTrieRoot:types.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, IsSealV0:false, AsSealV0:types.SealV0{Signer:0x0, Signature:types.Signature{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsConsensus:false, AsConsensus:types.Consensus{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsSeal:false, AsSeal:types.Seal{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsPreRuntime:true, AsPreRuntime:types.PreRuntime{ConsensusEngineID:0x45424142, Bytes:types.Bytes{0x2, 0x0, 0x0, 0x0, 0x0, 0xa7, 0xeb, 0x33, 0x1f, 0x0, 0x0, 0x0, 0x0}}}, types.DigestItem{IsOther:false, AsOther:types.Bytes(nil), IsAuthoritiesChange:false, AsAuthoritiesChange:[]types.AuthorityID(nil), IsChangesTrieRoot:false, AsChangesTrieRoot:types.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, IsSealV0:false, AsSealV0:types.SealV0{Signer:0x0, Signature:types.Signature{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsConsensus:false, AsConsensus:types.Consensus{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsSeal:true, AsSeal:types.Seal{ConsensusEngineID:0x45424142, Bytes:types.Bytes{0x4a, 0x47, 0x5, 0x3, 0x5, 0x2c, 0x53, 0x8b, 0x5b, 0xd7, 0x5, 0x25, 0x47, 0xcc, 0x1f, 0xae, 0x4, 0x3b, 0x8a, 0xee, 0x56, 0xe7, 0x50, 0xd6, 0xde, 0x87, 0x4d, 0xff, 0x90, 0x4d, 0x7a, 0x2b, 0x48, 0x8c, 0xcb, 0x77, 0x49, 0xfa, 0x74, 0x2e, 0x54, 0x76, 0x91, 0xc5, 0x84, 0xa7, 0x5f, 0x2e, 0xa0, 0x8d, 0x28, 0xf7, 0xd9, 0xf6, 0xb, 0xb7, 0x33, 0xf1, 0x18, 0xc5, 0x4, 0x2c, 0x6f, 0x8e}}, IsPreRuntime:false, AsPreRuntime:types.PreRuntime{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}}}}, Extrinsics:[]types.Extrinsic{"0x280302000b088d71a86d01", "0x14030d001916"}}, Justification:types.Justification(nil)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*types.Header(&types.Header{ParentHash:types.Hash{0xf6, 0xe0, 0xf9, 0xd, 0x27, 0x57, 0x8a, 0x18, 0xfc, 0x22, 0xcf, 0x10, 0x83, 0x3d, 0x7f, 0xb2, 0x86, 0xf9, 0x78, 0xce, 0x4e, 0x41, 0x1e, 0x87, 0xb2, 0x19, 0xc1, 0xd4, 0x98, 0xf6, 0xd3, 0x2c}, Number:0x0, StateRoot:types.Hash{0x2e, 0x5e, 0x1e, 0xa0, 0x5f, 0xcd, 0xec, 0xca, 0xa, 0xa, 0xf0, 0xe9, 0x8d, 0xc5, 0xc3, 0x20, 0xcb, 0x62, 0x13, 0xad, 0xc2, 0x1f, 0x4f, 0xad, 0x2c, 0xf, 0xfc, 0x74, 0x7a, 0x18, 0x64, 0xc}, ExtrinsicsRoot:types.Hash{0xc4, 0x5f, 0x66, 0x5d, 0x47, 0xe4, 0x8e, 0x54, 0xf, 0x1c, 0x89, 0xd8, 0x7e, 0x8, 0x79, 0xb8, 0x0, 0x53, 0x34, 0xf0, 0x6e, 0x53, 0x7d, 0xaa, 0x7c, 0xe8, 0xab, 0x51, 0xcc, 0x12, 0x39, 0x1b}, Digest:types.Digest{types.DigestItem{IsOther:false, AsOther:types.Bytes(nil), IsAuthoritiesChange:false, AsAuthoritiesChange:[]types.AuthorityID(nil), IsChangesTrieRoot:false, AsChangesTrieRoot:types.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, IsSealV0:false, AsSealV0:types.SealV0{Signer:0x0, Signature:types.Signature{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsConsensus:false, AsConsensus:types.Consensus{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsSeal:false, AsSeal:types.Seal{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsPreRuntime:true, AsPreRuntime:types.PreRuntime{ConsensusEngineID:0x45424142, Bytes:types.Bytes{0x2, 0x0, 0x0, 0x0, 0x0, 0xd9, 0xe8, 0x33, 0x1f, 0x0, 0x0, 0x0, 0x0}}}, types.DigestItem{IsOther:false, AsOther:types.Bytes(nil), IsAuthoritiesChange:false, AsAuthoritiesChange:[]types.AuthorityID(nil), IsChangesTrieRoot:false, AsChangesTrieRoot:types.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, IsSealV0:false, AsSealV0:types.SealV0{Signer:0x0, Signature:types.Signature{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsConsensus:false, AsConsensus:types.Consensus{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}, IsSeal:true, AsSeal:types.Seal{ConsensusEngineID:0x45424142, Bytes:types.Bytes{0xaa, 0x3f, 0x2f, 0x1, 0x50, 0x15, 0x4a, 0x9a, 0x6c, 0xe6, 0xb8, 0xf5, 0x18, 0x28, 0x8b, 0xc2, 0x92, 0xb2, 0x1, 0xf8, 0x36, 0x32, 0xdc, 0xf9, 0xeb, 0xd, 0x2d, 0x0, 0x5a, 0x38, 0xde, 0x2a, 0xa3, 0x67, 0x45, 0x31, 0xc7, 0x4, 0x46, 0x4e, 0xe6, 0x76, 0x88, 0x76, 0x83, 0x68, 0xba, 0xb8, 0x40, 0x11, 0x7, 0x6a, 0x35, 0xe8, 0xe6, 0xdd, 0x4a, 0xf5, 0x9d, 0xb4, 0x15, 0x5, 0x2f, 0x8d}}, IsPreRuntime:false, AsPreRuntime:types.PreRuntime{ConsensusEngineID:0x0, Bytes:types.Bytes(nil)}}}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// | ||
// Copyright 2019 Centrifuge GmbH | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package chain | ||
|
||
import ( | ||
"github.com/centrifuge/go-substrate-rpc-client/client" | ||
"github.com/centrifuge/go-substrate-rpc-client/types" | ||
) | ||
|
||
func (c *Chain) GetBlock(blockHash types.Hash) (*types.SignedBlock, error) { | ||
return c.getBlock(&blockHash) | ||
} | ||
|
||
func (c *Chain) GetBlockLatest() (*types.SignedBlock, error) { | ||
return c.getBlock(nil) | ||
} | ||
|
||
func (c *Chain) getBlock(blockHash *types.Hash) (*types.SignedBlock, error) { | ||
var SignedBlock types.SignedBlock | ||
err := client.CallWithBlockHash(*c.client, &SignedBlock, "chain_getBlock", blockHash) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &SignedBlock, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// Copyright (C) 2019 Centrifuge GmbH | ||
// | ||
// This file is part of Go Substrate RPC Client (GSRPC). | ||
// | ||
// GSRPC is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// GSRPC is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package chain | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestChain_GetBlockLatest(t *testing.T) { | ||
rv, err := chain.GetBlockLatest() | ||
assert.NoError(t, err) | ||
assert.Equal(t, &mockSrv.signedBlock, rv) | ||
} | ||
|
||
func TestChain_GetBlock(t *testing.T) { | ||
rv, err := chain.GetBlock(mockSrv.blockHashLatest) | ||
assert.NoError(t, err) | ||
assert.Equal(t, &mockSrv.signedBlock, rv) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// | ||
// Copyright 2019 Centrifuge GmbH | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package chain | ||
|
||
import ( | ||
"github.com/centrifuge/go-substrate-rpc-client/types" | ||
) | ||
|
||
func (c *Chain) GetFinalizedHead() (types.Hash, error) { | ||
var res string | ||
|
||
err := (*c.client).Call(&res, "chain_getFinalizedHead") | ||
if err != nil { | ||
return types.Hash{}, err | ||
} | ||
|
||
return types.NewHashFromHexString(res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// | ||
// Copyright 2019 Centrifuge GmbH | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package chain | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/centrifuge/go-substrate-rpc-client/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestChain_GetFinalizedHead(t *testing.T) { | ||
res, err := chain.GetFinalizedHead() | ||
assert.NoError(t, err) | ||
hex, err := types.Hex(res) | ||
assert.NoError(t, err) | ||
assert.Equal(t, mockSrv.blockHashLatest.Hex(), hex) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// | ||
// Copyright 2019 Centrifuge GmbH | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package chain | ||
|
||
import ( | ||
"github.com/centrifuge/go-substrate-rpc-client/client" | ||
"github.com/centrifuge/go-substrate-rpc-client/types" | ||
) | ||
|
||
func (c *Chain) GetHeader(blockHash types.Hash) (*types.Header, error) { | ||
return c.getHeader(&blockHash) | ||
} | ||
|
||
func (c *Chain) GetHeaderLatest() (*types.Header, error) { | ||
return c.getHeader(nil) | ||
} | ||
|
||
func (c *Chain) getHeader(blockHash *types.Hash) (*types.Header, error) { | ||
var Header types.Header | ||
err := client.CallWithBlockHash(*c.client, &Header, "chain_getHeader", blockHash) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Header, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls | ||
// Copyright (C) 2019 Centrifuge GmbH | ||
// | ||
// This file is part of Go Substrate RPC Client (GSRPC). | ||
// | ||
// GSRPC is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// GSRPC is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package chain | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestChain_GetHeaderLatest(t *testing.T) { | ||
rv, err := chain.GetHeaderLatest() | ||
assert.NoError(t, err) | ||
assert.Equal(t, &mockSrv.header, rv) | ||
} | ||
|
||
func TestChain_GetHeader(t *testing.T) { | ||
rv, err := chain.GetHeader(mockSrv.blockHashLatest) | ||
assert.NoError(t, err) | ||
assert.Equal(t, &mockSrv.header, rv) | ||
} |
Oops, something went wrong.