Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Commit

Permalink
FAB-11081 web3 integration tests
Browse files Browse the repository at this point in the history
 - test new functions based on existing values
 - getTransaction
 - getBlock with transaction hashes only
 - small tweak to getTransaction to format hash value as data

Change-Id: Ib371b005a4d87f3995b6388070672c9c25be53db
Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
  • Loading branch information
MHBauer committed Nov 20, 2018
1 parent 7a24ab4 commit e9600df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fabproxy/ethservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (s *ethService) GetTransactionByHash(r *http.Request, txID *string, reply *
fmt.Println("GetTransactionByHash", strippedTxId) // logging input to function

txn := Transaction{
Hash: *txID,
Hash: "0x" + strippedTxId,
}

block, err := s.ledgerClient.QueryBlockByTxID(fab.TransactionID(strippedTxId))
Expand Down
18 changes: 18 additions & 0 deletions integration/web3/web3_e2e_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ function TestVotingContract(fabProxyAddress1, fabProxyAddress2){
var user2VotingContract = user2.eth.contract(vote.votingContractABI)

var deployedContract = user1VotingContract.new(['a','b'], {data: vote.compiledVotingContract})
var contractTransaction = user1.eth.getTransaction(deployedContract.transactionHash)
if ( ! contractTransaction.input.includes(vote.compiledVotingContract) ){
console.log("getTransaction should return transaction with full details that includes the compiled contract")
console.log(contractTransaction)
console.log(vote.compiledVotingContract)
console.log(contractTransaction.input)
process.exit(1)
}
var contractTransactionBlock = user1.eth.getBlock(contractTransaction.blockNumber, false)
if ( contractTransactionBlock.transactions[contractTransaction.transactionIndex] != contractTransaction.hash ) {
console.log("getBlock should have a block with the same transaction as before")
console.log(contractTransactionBlock)
console.log(contractTransaction)
process.exit(1)
}

var contractAddress = user1.eth.getTransactionReceipt(deployedContract.transactionHash).contractAddress
var user1Contract = user1VotingContract.at(contractAddress)
var user2Contract = user2VotingContract.at(contractAddress)
Expand Down Expand Up @@ -71,6 +87,8 @@ function TestVotingContract(fabProxyAddress1, fabProxyAddress2){

// User2 should be able to vote
user2Contract.vote('0')

// Check the votes
CheckProposal(user1Contract.proposals('0'), 'a',2)
CheckProposal(user1Contract.proposals('1'), 'b',0)

Expand Down

0 comments on commit e9600df

Please sign in to comment.