New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get transaction with status api route #1969
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
node/nodeTransactions.go
Outdated
}, nil | ||
} | ||
|
||
func (n *Node) computeTransactionStatus(tx data.TransactionHandler, isInPool bool) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return TransactionStatus
here, and perhaps also use this type for the new tx field - and let the marshelizer do its job (optional - and hopefully it will work).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json marshaler will be happy with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes maybe json marshalizer will be happy with that but if we change core.TransactionStatus in a more complex structure that contains more than a single 'string'
field will not work anymore. if you strongly suggest that ,i will change... wait for your answer.
node/nodeTransactions.go
Outdated
}, nil | ||
} | ||
|
||
func (n *Node) computeTransactionStatus(tx data.TransactionHandler, isInPool bool) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json marshaler will be happy with that.
node/nodeTransactions_test.go
Outdated
@@ -294,6 +296,97 @@ func TestNode_GetTransaction_ShouldNotFindAndReturnUnknown(t *testing.T) { | |||
assert.Error(t, err) | |||
} | |||
|
|||
func TestNode_ComputeTransactionStatusAllBranches(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the suffix "AllBranches" perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
node/nodeTransactions_test.go
Outdated
rwdTxCrossShard := &rewardTx.RewardTx{RcvAddr: shardZeroAddr} | ||
normalTxIntraShard := &transaction.Transaction{RcvAddr: shardZeroAddr, SndAddr: shardZeroAddr} | ||
normalTxCrossShard := &transaction.Transaction{RcvAddr: shardOneAddr, SndAddr: shardZeroAddr} | ||
unsignedTxIntraShard := &smartContractResult.SmartContractResult{RcvAddr: shardOneAddr, SndAddr: shardZeroAddr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is cross shard. Also add another one for intra-shard :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
txStatus = n.ComputeTransactionStatus(unsignedTxIntraShard, true) | ||
assert.Equal(t, core.TxStatusReceived, txStatus) | ||
|
||
// cross shard scr in storage source shard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-shard, on destination, for rewards - not covered. But the test is sufficient though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think is sufficient because all branches are covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System tests passed.
Removed api route
/transaction/:hash/status
because a single observer cannot provided a correct status of a transaction (the case when a transaction is cross shard)Modified api route
/transaction/:hash
to return also transaction status from view of a obsever (is not 100% correct because an observer from shard 0 cannot know what is the status of a transaction from shard 1). Processing of a correct status of a transaction will be done on proxy application.