Skip to content
Snippets Groups Projects
Commit 80ad026c authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Made insert.sh and verify.sh behave a bit more as documented

parent 1fb9fecc
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,17 @@
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
contract=$1
text=$2
test -n "${contract}" ||
contract="TimestampDocument"
contract="TimeStampAuthority"
if [ $# -eq 0 ]
then
text="Hello World!"
elif [ $# -eq 1 ]
then
text="$1"
else
contract="$1"
text="$2"
fi
if [ ! -e "${contract}" -a -r "${BFANETWORKDIR}/contracts/${contract}" ]
then
contract=${BFANETWORKDIR}/contracts/${contract}
......@@ -16,17 +23,20 @@ test -L "${contract}" &&
test -n "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${contract}/abi )
abi=$( cat ${BFANETWORKDIR}/contracts/${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( bfamktemp )
js=$( mktemp )
sum=$( echo $text | sha256sum | cut -c -64 )
cleanup "$js"
cat > $js <<EOT
var mycontract = eth.contract(JSON.parse(${abi}))
var thecontract = mycontract.at("${basecontract}");
console.log ( thecontract.storeDocument.sendTransaction( "${text}", {from: eth.accounts[0], gas: 1000000} ) )
var mycontract = eth.contract(${abi})
var thecontract = mycontract.at("${basecontract}")
console.log ( thecontract.put.sendTransaction( "${sum}", {from: eth.accounts[0], gas: 1000000} ) )
EOT
out=$( bfamktemp )
geth --datadir node1 --exec "loadScript(\"${js}\")" attach ipc:node1/geth.ipc > ${out}
out=$( mktemp )
cleanup "$out"
geth_exec_js "${js}" > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
trans=` head -1 < ${out} `
......
......@@ -4,10 +4,17 @@
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
contract=$1
text=$2
test -n "${contract}" ||
contract="TimestampDocument"
contract="TimestampDocument"
if [ $# -eq 0 ]
then
text="Hello World!"
elif [ $# -eq 1 ]
then
text="$1"
else
contract="$1"
text="$2"
fi
if [ ! -e "${contract}" -a -r "${BFANETWORKDIR}/contracts/${contract}" ]
then
contract=${BFANETWORKDIR}/contracts/${contract}
......@@ -20,13 +27,15 @@ test -n "${basecontract}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( bfamktemp )
js=$( mktemp )
cleanup "$js"
cat > ${js} <<EOT
var mycontract = eth.contract(JSON.parse(${abi}))
var thecontract = mycontract.at("${basecontract}");
console.log ( thecontract.checkDocument.call( "${text}" ) )
EOT
out=$( bfamktemp )
out=$( mktemp )
cleanup "$out"
geth --datadir node1 --exec "loadScript(\"${js}\")" attach ipc:node1/geth.ipc > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment