Skip to content

Commit

Permalink
feat: OracleRespondTx integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed Apr 30, 2019
1 parent 680262a commit d7c5696
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aeternity/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ func (o *Oracle) OracleQueryTx(OracleID, Query string, QueryFee utils.BigInt, Qu
return tx, nil
}

func (o *Oracle) OracleRespondTx(OracleID string, QueryID string, Response string, TTLType uint64, TTLValue uint64) (tx OracleRespondTx, err error) {
ttl, nonce, err := getTTLNonce(o.nodeClient, o.owner.Address, Config.Client.TTL)
if err != nil {
return OracleRespondTx{}, err
}

tx = NewOracleRespondTx(OracleID, nonce, QueryID, Response, TTLType, TTLValue, Config.Client.Fee, ttl)
return tx, nil
}

// StoreAccountToKeyStoreFile store an account to a json file
func StoreAccountToKeyStoreFile(account *Account, password, walletName string) (filePath string, err error) {
// keystore will be saved in current directory
Expand Down
15 changes: 15 additions & 0 deletions integration_test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,19 @@ func TestOracleWorkflow(t *testing.T) {
}
waitForTransaction(aeClient, oracleQueryTxHash)

fmt.Println("OracleRespondTx")
// Find the Oracle Query ID to reply to
oracleQueries, err := aeClient.APIGetOracleQueriesByPubkey(oraclePubKey)
if err != nil {
t.Errorf("APIGetOracleQueriesByPubkey: %s", err)
}
oqID := string(oracleQueries.OracleQueries[0].ID)
oracleRespondTx, err := aeClient.Oracle.OracleRespondTx(oraclePubKey, oqID, "My day was fine thank you", 0, 100)
oracleRespondTxStr, _ := aeternity.BaseEncodeTx(&oracleRespondTx)
oracleRespondTxHash, err := signBroadcast(oracleRespondTxStr, acc, aeClient)
if err != nil {
t.Error(err)
}
waitForTransaction(aeClient, oracleRespondTxHash)

}

0 comments on commit d7c5696

Please sign in to comment.