Skip to content

Commit 937ad4e

Browse files
committed
only TriggerSmartContract check transaction contractRet
1 parent a07a5ff commit 937ad4e

7 files changed

+29
-26
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ release
33
.vscode
44
.idea
55
*.key
6+
openwtester/conf

openwtester/subscribe_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ func TestSubscribeAddress(t *testing.T) {
5858
var (
5959
endRunning = make(chan bool, 1)
6060
symbol = "TRX"
61-
//accountID = "CfRjWjct569qp7oygSA2LrsAoTrfEB8wRk3sHGUj9Erm"
62-
accountID = "6msrcfed9rA7njVNDtY1Ppo9XQdX5p3SFPc1zxWgd8ut"
6361
addrs = map[string]string{
64-
"TT44ohw23WGNv1jQCAUN3etUWND1KXN2Eq": accountID,
65-
"TJLypjev8iLdQR3X63rSMeZK8GKwkeSH1Y": accountID,
62+
"TEzdWXvMNE7sBxuQ2N98EX4kEJajQgz5rM": "sender",
63+
"TRJJ9Mq4aMjdmKWpTDJAgbYNoY2P9Facg5": "receiver",
6664
}
6765
)
6866

@@ -92,7 +90,7 @@ func TestSubscribeAddress(t *testing.T) {
9290

9391
//log.Debug("already got scanner:", assetsMgr)
9492
scanner := assetsMgr.GetBlockScanner()
95-
scanner.SetRescanBlockHeight(7848677)
93+
scanner.SetRescanBlockHeight(10438073)
9694

9795
if scanner == nil {
9896
log.Error(symbol, "is not support block scan")

openwtester/transaction_manager_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,24 @@ func TestWalletManager_GetAssetsAccountTokenBalance(t *testing.T) {
130130
// Protocol: "trc20",
131131
//}
132132

133-
//contract := openwallet.SmartContract{
134-
// Address: "THvZvKPLHKLJhEFYKiyqj6j8G8nGgfg7ur",
135-
// Symbol: "TRX",
136-
// Name: "TRONdice",
137-
// Token: "DICE",
138-
// Decimals: 6,
139-
// Protocol: "trc20",
140-
//}
141-
142133
contract := openwallet.SmartContract{
143-
Address: "1002000",
134+
Address: "THvZvKPLHKLJhEFYKiyqj6j8G8nGgfg7ur",
144135
Symbol: "TRX",
145-
Name: "BitTorrent",
146-
Token: "BTT",
147-
Decimals: 0,
148-
Protocol: "trc10",
136+
Name: "TRONdice",
137+
Token: "DICE",
138+
Decimals: 6,
139+
Protocol: "trc20",
149140
}
150141

142+
//contract := openwallet.SmartContract{
143+
// Address: "1002000",
144+
// Symbol: "TRX",
145+
// Name: "BitTorrent",
146+
// Token: "BTT",
147+
// Decimals: 0,
148+
// Protocol: "trc10",
149+
//}
150+
151151
balance, err := tm.GetAssetsAccountTokenBalance(testApp, walletID, accountID, contract)
152152
if err != nil {
153153
log.Error("GetAssetsAccountTokenBalance failed, unexpected error:", err)

openwtester/transcation_assets_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func TestTransfer_TRC20(t *testing.T) {
179179

180180
testGetAssetsAccountTokenBalance(tm, walletID, accountID, contract)
181181

182-
rawTx, err := testCreateTransactionStep(tm, walletID, accountID, to, "9.5", "", &contract)
182+
rawTx, err := testCreateTransactionStep(tm, walletID, accountID, to, "1", "", &contract)
183183
if err != nil {
184184
return
185185
}

tron/blockscanner.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,16 @@ func (bs *TronBlockScanner) InitTronExtractResult(tx *Contract, result *ExtractR
424424

425425
status := "1"
426426
reason := ""
427-
if tx.ContractRet != SUCCESS {
428-
status = "0"
429-
reason = tx.ContractRet
427+
428+
//TRC20转账才需要判断ContractRet状态
429+
if tx.Type == TriggerSmartContract {
430+
if tx.ContractRet != SUCCESS {
431+
status = "0"
432+
reason = tx.ContractRet
433+
}
430434
}
435+
436+
431437
amount := decimal.Zero
432438
coin := openwallet.Coin{
433439
Symbol: bs.wm.Symbol(),

tron/blockscanner_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestTron_GetGlobalMaxBlockHeight(t *testing.T) {
110110

111111
func TestTron_GetTransaction(t *testing.T) {
112112
bs := NewTronBlockScanner(tw)
113-
txID := "d414c54f51792e9383e9b9a19b67f0f34e8a3eccf3059757b8ea9a1b5a7de86c"
113+
txID := "003712cddc2be86184a6b6d396e726d4549975dc6938e5f88bfcb627960886b8"
114114
height := uint64(7773685)
115115
tx, err := bs.wm.GetTransaction(txID, "", height, 0)
116116
if err != nil {

tron/manager_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ func init() {
3232
tw = NewWalletManager()
3333

3434
//tw.Config.ServerAPI = "http://127.0.0.1:28090"
35-
// tw.Config.ServerAPI = "http://127.0.0.1:18090"
36-
//tw.Config.ServerAPI = "http://192.168.2.194:18090"
3735
tw.Config.ServerAPI = "https://api.trongrid.io"
3836
tw.Config.IsTestNet = false
3937
// tw.Config.RpcUser = "walletUser"

0 commit comments

Comments
 (0)