github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/rpc/client_integration_test.go (about) 1 //go:build integration 2 // +build integration 3 4 // Copyright 2021 The TrueBlocks Authors. All rights reserved. 5 // Use of this source code is governed by a license that can 6 // be found in the LICENSE file. 7 8 package rpc 9 10 import ( 11 "testing" 12 13 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 14 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" 15 ) 16 17 func Test_Client(t *testing.T) { 18 conn := TempConnection(utils.GetTestChain()) 19 20 chainId, networkId, _ := conn.GetClientIDs() 21 if chainId != networkId || chainId != 1 { 22 t.Error("provider chain id is 1") 23 } 24 25 ts := conn.GetBlockTimestamp(1) 26 blockOneTimestamp := base.Timestamp(1438269988) 27 if ts != blockOneTimestamp { 28 t.Error("timestamp for block 1 is not correct") 29 } 30 31 _, err := conn.GetTransactionHashByHash("0x730724cb08a6eb17bf6b3296359d261570d343ea7944a17a9d7287d77900db08") 32 if err != nil { 33 t.Error("couldn't get known transaction hash from tx hash") 34 } 35 36 _, err = conn.GetTransactionHashByHashAndID("0x0b4c6fb75ded4b90218cf0346b0885e442878f104e1b60bf75d5b6860eeacd53", 0) 37 if err != nil { 38 t.Error("couldn't get known transaction hash from block hash and tx id") 39 } 40 41 _, err = conn.GetBlockHashByHash("0x0b4c6fb75ded4b90218cf0346b0885e442878f104e1b60bf75d5b6860eeacd53") 42 if err != nil { 43 t.Error("couldn't get known block hash from block hash") 44 } 45 46 _, err = conn.GetBlockHashByNumber(12) 47 if err != nil { 48 t.Error("couldn't get known block hash from block number") 49 } 50 } 51 52 func Test_TxFromNumberAndId(t *testing.T) { 53 conn := TempConnection(utils.GetTestChain()) 54 _, err := conn.GetTransactionHashByNumberAndID(1424623, 0) 55 if err != nil { 56 t.Fatal(err) 57 } 58 }