Commit 209dceff authored by vipwzw's avatar vipwzw Committed by 33cn

fix linter

parent 3b66a970
...@@ -93,7 +93,6 @@ func newParaChainAPI(api client.QueueProtocolAPI, grpcaddr string) ExecutorAPI { ...@@ -93,7 +93,6 @@ func newParaChainAPI(api client.QueueProtocolAPI, grpcaddr string) ExecutorAPI {
if paraRemoteGrpcClient == "" { if paraRemoteGrpcClient == "" {
paraRemoteGrpcClient = "127.0.0.1:8002" paraRemoteGrpcClient = "127.0.0.1:8002"
} }
println("------", paraRemoteGrpcClient)
conn, err := grpc.Dial(paraRemoteGrpcClient, grpc.WithInsecure()) conn, err := grpc.Dial(paraRemoteGrpcClient, grpc.WithInsecure())
if err != nil { if err != nil {
panic(err) panic(err)
......
...@@ -34,6 +34,11 @@ func TestAPI(t *testing.T) { ...@@ -34,6 +34,11 @@ func TestAPI(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, randhash, []byte("hello")) assert.Equal(t, randhash, []byte("hello"))
assert.Equal(t, false, eapi.IsErr()) assert.Equal(t, false, eapi.IsErr())
api.On("QueryTx", mock.Anything).Return(&types.TransactionDetail{Height: 1}, nil)
param3 := &types.ReqHash{Hash: []byte("hash")}
txdetail, err := eapi.QueryTx(param3)
assert.Nil(t, err)
assert.Equal(t, int64(1), txdetail.Height)
types.SetTitleOnlyForTest("user.p.wzw.") types.SetTitleOnlyForTest("user.p.wzw.")
//testnode setup //testnode setup
rpcCfg := new(types.RPC) rpcCfg := new(types.RPC)
...@@ -63,6 +68,10 @@ func TestAPI(t *testing.T) { ...@@ -63,6 +68,10 @@ func TestAPI(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, randhash, []byte("hello")) assert.Equal(t, randhash, []byte("hello"))
assert.Equal(t, false, eapi.IsErr()) assert.Equal(t, false, eapi.IsErr())
param3 = &types.ReqHash{Hash: []byte("hash")}
txdetail, err = eapi.QueryTx(param3)
assert.Nil(t, err)
assert.Equal(t, int64(1), txdetail.Height)
//queue err //queue err
assert.Equal(t, false, IsQueueError(nil)) assert.Equal(t, false, IsQueueError(nil))
assert.Equal(t, false, IsQueueError(errors.New("xxxx"))) assert.Equal(t, false, IsQueueError(errors.New("xxxx")))
......
...@@ -400,7 +400,10 @@ func (d *DriverBase) GetHeight() int64 { ...@@ -400,7 +400,10 @@ func (d *DriverBase) GetHeight() int64 {
// GetMainHeight return height // GetMainHeight return height
func (d *DriverBase) GetMainHeight() int64 { func (d *DriverBase) GetMainHeight() int64 {
return d.mainHeight if types.IsPara() {
return d.mainHeight
}
return d.height
} }
// GetBlockTime return block time // GetBlockTime return block time
......
...@@ -76,7 +76,8 @@ func TestDriverAPI(t *testing.T) { ...@@ -76,7 +76,8 @@ func TestDriverAPI(t *testing.T) {
demo := LoadDriverAllow(tx, 0, 1).(*demoApp) demo := LoadDriverAllow(tx, 0, 1).(*demoApp)
dir, ldb, kvdb := util.CreateTestDB() dir, ldb, kvdb := util.CreateTestDB()
defer util.CloseTestDB(dir, ldb) defer util.CloseTestDB(dir, ldb)
demo.SetEnv(1, time.Now().Unix(), 1, []byte("parentHash"), []byte("mainHash")) demo.SetEnv(1, time.Now().Unix(), 1)
demo.SetBlockInfo([]byte("parentHash"), []byte("mainHash"), 1)
demo.SetLocalDB(kvdb) demo.SetLocalDB(kvdb)
demo.SetStateDB(kvdb) demo.SetStateDB(kvdb)
demo.SetAPI(&mocks.QueueProtocolAPI{}) demo.SetAPI(&mocks.QueueProtocolAPI{})
...@@ -88,7 +89,7 @@ func TestDriverAPI(t *testing.T) { ...@@ -88,7 +89,7 @@ func TestDriverAPI(t *testing.T) {
types.SetTitleOnlyForTest("user.p.wzw.") types.SetTitleOnlyForTest("user.p.wzw.")
assert.Equal(t, "parentHash", string(demo.GetParentHash())) assert.Equal(t, "parentHash", string(demo.GetParentHash()))
assert.Equal(t, "mainHash", string(demo.GetLastHash())) assert.Equal(t, "mainHash", string(demo.GetLastHash()))
assert.Equal(t, int64(1), demo.GetMainHeight())
assert.Equal(t, true, IsDriverAddress(ExecAddress("none"), 0)) assert.Equal(t, true, IsDriverAddress(ExecAddress("none"), 0))
assert.Equal(t, false, IsDriverAddress(ExecAddress("demo"), 0)) assert.Equal(t, false, IsDriverAddress(ExecAddress("demo"), 0))
assert.Equal(t, true, IsDriverAddress(ExecAddress("demo"), 1)) assert.Equal(t, true, IsDriverAddress(ExecAddress("demo"), 1))
......
...@@ -10,15 +10,15 @@ message Genesis { ...@@ -10,15 +10,15 @@ message Genesis {
} }
message ExecTxList { message ExecTxList {
bytes stateHash = 1; bytes stateHash = 1;
bytes parentHash = 7; bytes parentHash = 7;
bytes mainHash = 8; bytes mainHash = 8;
int64 mainHeight = 9; int64 mainHeight = 9;
int64 blockTime = 3; int64 blockTime = 3;
int64 height = 4; int64 height = 4;
uint64 difficulty = 5; uint64 difficulty = 5;
bool isMempool = 6; bool isMempool = 6;
repeated Transaction txs = 2; repeated Transaction txs = 2;
} }
message Query { message Query {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment