[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30446 - in gnunet-java: . bin src/main/java/org/gnunet/mes
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30446 - in gnunet-java: . bin src/main/java/org/gnunet/mesh src/main/java/org/gnunet/util src/main/java/org/gnunet/util/crypto src/main/java/org/gnunet/voting src/main/java/org/gnunet/voting/messages src/test src/test/bash tools |
Date: |
Tue, 29 Oct 2013 03:37:49 +0100 |
Author: dold
Date: 2013-10-29 03:37:48 +0100 (Tue, 29 Oct 2013)
New Revision: 30446
Added:
gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignedMessage.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignedMessage.java
gnunet-java/src/test/bash/
gnunet-java/src/test/bash/test_voting.conf
gnunet-java/src/test/bash/test_voting_simple.sh
Modified:
gnunet-java/ISSUES
gnunet-java/bin/gnunet-daemon-ballot-tally
gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
gnunet-java/src/main/java/org/gnunet/util/RelativeTime.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaPrivateKey.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaPrivateKey.java
gnunet-java/src/main/java/org/gnunet/voting/Ballot.java
gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java
gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
gnunet-java/src/main/java/org/gnunet/voting/messages/SubmitFailureMessage.java
gnunet-java/tools/build
Log:
- automatic test for voting
- signed messages
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/ISSUES 2013-10-29 02:37:48 UTC (rev 30446)
@@ -1,3 +1,28 @@
+there were still some [gnunetd] sections, should I delete them if I see one?
+
+gnunet-java now has EcdsaSignedMessage<M> and EddsaSignedMessage<M>,
+the design is a bit different from C GNUnet and replaces the
E(c|d)dsaSignaturePurpose
+
+mesh: what config value do I have to tweak so that a newly started
+listening mesh handle receives a tunnel that has been created before?
+ * is this even possible?
+
+I've implemented automatic tests in bash
+ * somewhat elaborate bash hacking
+ * see cleanup (better alternatives?)
+ * killing the JVM properly (see gnunet-daemon-ballot-tally)
+ * authorities have to be entered into the ballot on the fly
+ * ... same with timestamps
+ * ... and identities
+ * some aspects are not possible to test due to crypto mismatch
+ * bash tests aren't run by gradle automatically (yet)
+
+gnunet-config has no way to delete an option :-(
+
+---------------------------------------
+
+
+
transport:
* documentation for StartMessage seems totally wrong, am I missing something?
Modified: gnunet-java/bin/gnunet-daemon-ballot-tally
===================================================================
--- gnunet-java/bin/gnunet-daemon-ballot-tally 2013-10-28 16:37:04 UTC (rev
30445)
+++ gnunet-java/bin/gnunet-daemon-ballot-tally 2013-10-29 02:37:48 UTC (rev
30446)
@@ -1,5 +1,13 @@
-#!/bin/sh
+#!/bin/bash
+function cleanup {
+ if [[ ${PID:+x} ]]; then
+ kill -9 $PID
+ fi
+}
+
+trap cleanup EXIT
+
if [ "%GNJ_INSTALLED" = "true" ];
then
export CLASSPATH="%INSTALL_PATH/share/java/*"
@@ -9,4 +17,7 @@
export
CLASSPATH="$DIR/../build-gradle/classes/main/:$DIR/../build-gradle/resources/main/:$DIR/../lib/*"
fi
-java -ea org.gnunet.voting.TallyAuthorityDaemon "$@"
+java -ea org.gnunet.voting.TallyAuthorityDaemon "$@" &
+PID=$!
+wait $PID
+unset PID
Modified: gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2013-10-28 16:37:04 UTC
(rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2013-10-29 02:37:48 UTC
(rev 30446)
@@ -320,13 +320,17 @@
this.ports = ports;
this.inboundTunnelHandler = inboundTunnelHandler;
- logger.debug("mesh handle created");
-
client = new Client("mesh", cfg);
client.installReceiver(new MeshMessageReceiver());
ClientConnectMessage ccm = new ClientConnectMessage();
ccm.applicationList = ports;
+ String portList = "";
+ for (int p : ports) {
+ portList += "" + p + " ";
+ }
client.send(ccm);
+
+ logger.debug("mesh handle created, listening on ports {}", portList);
}
/**
@@ -345,6 +349,11 @@
return new Tunnel<T>(peer, port, nobuffer, reliable, initialContext);
}
+ public <T> Tunnel<T> createTunnel(PeerIdentity peer, int port, boolean
nobuffer, boolean reliable) {
+ logger.debug("creating tunnel to peer {} over port {}",
peer.toString(), port);
+ return new Tunnel<T>(peer, port, nobuffer, reliable, null);
+ }
+
/**
* Disconnect from the mesh service.
* All tunnels will be destroyed.
Modified: gnunet-java/src/main/java/org/gnunet/util/RelativeTime.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/RelativeTime.java 2013-10-28
16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/util/RelativeTime.java 2013-10-29
02:37:48 UTC (rev 30446)
@@ -210,7 +210,6 @@
-
public RelativeTimeMessage toNetwork() {
long rval = this.rel_value_us;
assert rval >= 0;
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaPrivateKey.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaPrivateKey.java
2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaPrivateKey.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -23,7 +23,17 @@
}
public EcdsaPublicKey getPublicKey() {
- return EcdsaPublicKey.random();
+ // FIXME: this is not the real implementation,
+ // beware that this dummy implementation leaks the key!
+ EcdsaPublicKey publicKey = new EcdsaPublicKey();
+ byte[] v = new byte[32];
+ System.arraycopy(d, 0, v, 0, 8);
+ System.arraycopy(d, 0, v, 8, 8);
+ System.arraycopy(d, 0, v, 16, 8);
+ System.arraycopy(d, 0, v, 24, 8);
+ System.arraycopy(v, 0, publicKey.x, 0, 32);
+ System.arraycopy(v, 0, publicKey.y, 0, 32);
+ return publicKey;
}
public static EcdsaPrivateKey createRandom() {
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -48,7 +48,7 @@
this.s = new byte[32];
}
- public boolean verify(byte[] m, int purpose, EddsaPublicKey publicKey) {
+ public boolean verify(byte[] m, int purpose, EcdsaPublicKey publicKey) {
return false;
}
Added: gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignedMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignedMessage.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignedMessage.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -0,0 +1,60 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+package org.gnunet.util.crypto;
+
+import org.gnunet.construct.Construct;
+import org.gnunet.construct.Message;
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt32;
+
+/**
+ * A message together with a signature on the message and it's purpose.
+ */
+public class EcdsaSignedMessage<M extends Message> implements Message {
+ @NestedMessage
+ public EcdsaSignature signature;
+ @UInt32
+ public int purpose;
+ @NestedMessage
+ public M innerMessage;
+
+ public EcdsaSignedMessage() {
+ // empty constructor required by org.gnunet.construct
+ }
+
+ public boolean verify(EcdsaPublicKey signerPublicKey) {
+ return signature.verify(Construct.toBinary(innerMessage), purpose,
signerPublicKey);
+ }
+
+ public static <T extends Message> EcdsaSignedMessage<T> signMessage(T
innerMessage, int purpose,
+ EcdsaPrivateKey privateKey,
EcdsaPublicKey publicKey) {
+ EcdsaSignedMessage<T> esm = new EcdsaSignedMessage<T>();
+ esm.purpose = purpose;
+ esm.innerMessage = innerMessage;
+ esm.signature = privateKey.sign(purpose,
Construct.toBinary(innerMessage));
+ return esm;
+ }
+
+ public static <T extends Message> EcdsaSignedMessage<T> signMessage(T
innerMessage, int purpose,
+ EcdsaPrivateKey privateKey) {
+ return signMessage(innerMessage, purpose, privateKey,
privateKey.getPublicKey());
+ }
+}
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaPrivateKey.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaPrivateKey.java
2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaPrivateKey.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -13,6 +13,10 @@
@FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
public byte[] d;
+ public EddsaSignature sign(int purpose, byte[] m) {
+ return sign(getPublicKey(), purpose, m);
+ }
+
public EddsaSignature sign(EddsaPublicKey publicKey, int purpose, byte[]
m) {
MessageDigest sha512;
try {
Added: gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignedMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignedMessage.java
(rev 0)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignedMessage.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -0,0 +1,80 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/*
+ This file is part of GNUnet.
+ (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+package org.gnunet.util.crypto;
+
+import org.gnunet.construct.Construct;
+import org.gnunet.construct.Message;
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt32;
+
+/**
+ * A message together with a signature on the message and it's purpose.
+ */
+public class EddsaSignedMessage<M extends Message> implements Message {
+ @NestedMessage
+ public EddsaSignature signature;
+ @UInt32
+ public int purpose;
+ @NestedMessage
+ public M innerMessage;
+
+ public EddsaSignedMessage() {
+ // empty constructor required by org.gnunet.construct
+ }
+
+ public boolean verify(EddsaPublicKey signerPublicKey) {
+ return signature.verify(Construct.toBinary(innerMessage), purpose,
signerPublicKey);
+ }
+
+ public static <T extends Message> EddsaSignedMessage<T> signMessage(T
innerMessage, int purpose,
+ EddsaPrivateKey privateKey,
EddsaPublicKey publicKey) {
+ EddsaSignedMessage<T> esm = new EddsaSignedMessage<T>();
+ esm.purpose = purpose;
+ esm.innerMessage = innerMessage;
+ esm.signature = privateKey.sign(publicKey, purpose,
Construct.toBinary(innerMessage));
+ return esm;
+ }
+
+ public static <T extends Message> EddsaSignedMessage<T> signMessage(T
innerMessage, int purpose,
+ EddsaPrivateKey privateKey) {
+ return signMessage(innerMessage, purpose, privateKey,
privateKey.getPublicKey());
+ }
+}
Modified: gnunet-java/src/main/java/org/gnunet/voting/Ballot.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/Ballot.java 2013-10-28
16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/voting/Ballot.java 2013-10-29
02:37:48 UTC (rev 30446)
@@ -418,6 +418,8 @@
buf.append(" ");
}
buf.append("\n");
+ } else {
+ buf.append("ballot not registered");
}
if (!confirmationSigs.isEmpty()) {
buf.append("ballot's vote has been submitted to with the following
authorities:\n");
@@ -428,7 +430,7 @@
buf.append("\n");
}
else {
- buf.append("ballot not registered\n");
+ buf.append("ballot not submitted\n");
}
if (choiceId != -1) {
buf.append("choice selected\n");
@@ -529,9 +531,12 @@
if (this.groupCert != null) {
throw new InvalidBallotException("ballot already has group
information");
}
+ // FIXME: add this check again once the crypto is in sync
+ /*
if (voterPub != null &&
!groupCert.getMemberPublicKey().equals(voterPub)) {
throw new InvalidBallotException("group and voter public key do
not match");
}
+ */
voterPub = groupCert.getMemberPublicKey();
this.groupCert = groupCert;
}
Modified: gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java 2013-10-28
16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java 2013-10-29
02:37:48 UTC (rev 30446)
@@ -241,7 +241,7 @@
currentAuthority =
remainingAuthorities.get(r.nextInt(remainingAuthorities.size()));
System.out.println("registering ballot with authority " +
currentAuthority.toString());
mesh = new Mesh(getConfiguration(), new BallotTunnelEndHandler(),
new BallotRegisterReceiver());
- tunnel = mesh.createTunnel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true, null);
+ tunnel = mesh.createTunnel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true);
BallotRegisterRequestMessage m = new
BallotRegisterRequestMessage();
CompressedConfig ccfg = new
CompressedConfig(ballot.toConfiguration());
m.compressedBallotConfig = ccfg.compressedData;
@@ -250,7 +250,8 @@
}
if (issue) {
if (null == ego) {
- System.out.println("no ego given");
+ System.err.println("no ego given");
+ setReturnValue(1);
return;
}
ballot.issue(ego.getPrivateKey());
@@ -259,7 +260,8 @@
}
if (select != null) {
if (null == ego) {
- System.out.println("no ego given");
+ System.err.println("no ego given");
+ setReturnValue(1);
return;
}
ballot.encodeChoice(select, ego.getPrivateKey());
@@ -301,6 +303,7 @@
List<PeerIdentity> remainingAuthorities = ballot.getAuthorities();
if (remainingAuthorities.isEmpty()) {
System.err.println("no authorities available");
+ setReturnValue(2);
return;
}
Random r = new Random();
@@ -358,6 +361,7 @@
public static void main(String args[]) {
Program tool = new BallotTool(args);
- tool.start();
+ int ret = tool.start();
+ System.exit(ret);
}
}
Modified: gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -107,6 +107,7 @@
@Override
public void onDone() {
+ System.out.println("got element from consensus");
electionState.consensusDone = true;
electionState.consensus.destroy();
electionState.consensus = null;
@@ -151,7 +152,7 @@
+ electionState.ballot.startTime.toFancyString() + ",
now "
+ AbsoluteTime.now().toFancyString() + ")";
getSender().send(fm);
- } else if (!electionState.ballot.closingTime.isDue()) {
+ } else if (electionState.ballot.closingTime.isDue()) {
SubmitFailureMessage fm = new SubmitFailureMessage();
fm.reason = "too late to submit vote";
getSender().send(fm);
@@ -196,15 +197,17 @@
ElectionState electionState = new ElectionState();
electionState.tally = new int[b.choices.size()];
electionState.ballot = b;
+ PeerIdentity[] ids = new PeerIdentity[b.getAuthorities().size()];
+ ids = b.getAuthorities().toArray(ids);
electionState.consensus = new Consensus(getConfiguration(),
- (PeerIdentity[]) b.getAuthorities().toArray(),
+ ids,
b.getBallotGuid());
ConsensusConcludeTask t = new ConsensusConcludeTask(electionState);
if (b.concludeTime.isDue()) {
Scheduler.add(t);
} else {
- Scheduler.addDelayed(b.concludeTime.getRemaining(), t);
+ Scheduler.addDelayed(b.closingTime.getRemaining(), t);
}
elections.put(guid, electionState);
BallotRegisterSuccessMessage rm = new
BallotRegisterSuccessMessage();
@@ -220,7 +223,12 @@
rm.reason = "no matching ballot found";
getSender().send(rm);
} else {
- if (electionState.ballot.queryTime.isDue()) {
+ if (!electionState.consensusDone) {
+ QueryFailureMessage rm = new QueryFailureMessage();
+ rm.reason = "consensus not finished (sorry...)";
+ getSender().send(rm);
+ }
+ else if (electionState.ballot.queryTime.isDue()) {
QueryResponseMessage rm = new QueryResponseMessage();
rm.results = electionState.tally;
getSender().send(rm);
Modified:
gnunet-java/src/main/java/org/gnunet/voting/messages/SubmitFailureMessage.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/voting/messages/SubmitFailureMessage.java
2013-10-28 16:37:04 UTC (rev 30445)
+++
gnunet-java/src/main/java/org/gnunet/voting/messages/SubmitFailureMessage.java
2013-10-29 02:37:48 UTC (rev 30446)
@@ -21,12 +21,17 @@
package org.gnunet.voting.messages;
+import org.gnunet.construct.NestedMessage;
import org.gnunet.construct.UnionCase;
import org.gnunet.construct.ZeroTerminatedString;
+import org.gnunet.util.AbsoluteTimeMessage;
import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.crypto.EcdsaSignedMessage;
@UnionCase(42010)
public class SubmitFailureMessage implements GnunetMessage.Body {
@ZeroTerminatedString
public String reason;
+ @NestedMessage(optional = true)
+ public EcdsaSignedMessage<AbsoluteTimeMessage> authorityTime;
}
Added: gnunet-java/src/test/bash/test_voting.conf
===================================================================
--- gnunet-java/src/test/bash/test_voting.conf (rev 0)
+++ gnunet-java/src/test/bash/test_voting.conf 2013-10-29 02:37:48 UTC (rev
30446)
@@ -0,0 +1,11 @@
+[arm]
+DEFAULTSERVICES = mesh fs set consensus
+
+[mesh]
+AUTOSTART = YES
+
+[testbed]
+OVERLAY_TOPOLOGY = CLIQUE
+
+[nse]
+AUTOSTART = NO
Added: gnunet-java/src/test/bash/test_voting_simple.sh
===================================================================
--- gnunet-java/src/test/bash/test_voting_simple.sh
(rev 0)
+++ gnunet-java/src/test/bash/test_voting_simple.sh 2013-10-29 02:37:48 UTC
(rev 30446)
@@ -0,0 +1,160 @@
+#!/bin/bash
+
+# stop on non-zero exit value
+set -e
+# stop on using unset variable
+set -u
+
+# get the dir where our script runs from
+SDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# friendly reminder to have gnunet-java in path
+if [[ -z $(which gnunet-ballot) ]]; then
+ echo "no gnunet-ballot found, did you set PATH correctly?" 1>&2
+ exit 1
+fi
+
+
+# prefix for testing etc.
+PREFIX=$(mktemp -d test-voting-XXXXXXXXXX.d --tmpdir)
+
+echo "I'm in '$SDIR'"
+echo "prefix: $PREFIX"
+
+# authority config
+CFG0="$PREFIX/0/config"
+
+CLEAN=0
+function cleanup {
+ if [[ $CLEAN == 0 ]]; then
+ CLEAN=1
+ echo $1
+ kill $(jobs -p) &>/dev/null
+ sleep 5 && kill -9 $(jobs -p) &>/dev/null &
+ KILLER=$!
+ for PID in $(jobs -p); do
+ kill -0 $PID &>/dev/null
+ ALIVE=$?
+ if [[ $ALIVE && $PID != $KILLER ]]; then
+ wait $PID &>/dev/null
+ fi
+ done
+ kill $KILLER
+ fi
+ exit 1
+}
+
+trap 'cleanup "error in line $LINENO"' ERR
+trap "cleanup \"got sigint\"" SIGINT
+trap "cleanup \"exiting\"" EXIT
+
+export GNUNET_FORCE_LOG=";;;;ERROR"
+#export GNUNET_FORCE_LOG="mesh;;;;DEBUG"
+export GNUNET_TESTING_PREFIX=$PREFIX
+gnunet-testbed-profiler -n -c "$SDIR/test_voting.conf" -p 1 &
+
+gnunet-ballot -t "$PREFIX/ballot"
+
+gnunet-config -c "$PREFIX/ballot" -s election -o TOPIC -V mytopic
+
+PRIVKFILE=$(gnunet-config -f -c $CFG0 -s peer -o private_key)
+echo privkeyfile $PRIVKFILE
+
+PUBK=$(gnunet-ecc --print-public-key $PRIVKFILE)
+echo pubkey $PUBK
+
+PEERID=$(gnunet-ecc --print-peer-identity $PRIVKFILE)
+echo peerid $PEERID
+
+gnunet-config -c "$PREFIX/ballot" -s authorities -o auth1 -V "$PEERID"
+
+gnunet-identity -c $CFG0 -C ca
+gnunet-identity -c $CFG0 -C voter0
+gnunet-identity -c $CFG0 -C issuer
+
+function pubget {
+ gnunet-identity -c $CFG0 -d | grep "^$1 -" | sed 's/.*- *//g'
+}
+
+CA_PUB=$(pubget ca)
+V0_PUB=$(pubget voter0)
+
+echo V0_PUB $V0_PUB
+
+if [[ -z $CA_PUB ]]; then
+ echo "could not generate ca pubkey"
+ exit 1
+fi
+
+gnunet-config -c "$PREFIX/ballot" -s election -o CA_PUB -V "$CA_PUB"
+
+gnunet-config -c "$PREFIX/ballot" -s election -o GROUP -V "test voters"
+
+
+NOW=$(date +%s)
+
+declare -i TS_START=NOW+15
+declare -i TS_CLOSING=TS_START+5
+declare -i TS_CONCLUDE=TS_START+10
+declare -i TS_QUERY=TS_START+20
+declare -i TS_END=TS_START+500
+
+
+
+function settime {
+ local VAR="TS_$1"
+ gnunet-config -c "$PREFIX/ballot" -s election -o "TIMESTAMP_$1" -V ${!VAR}
+}
+
+settime START
+settime CLOSING
+settime CONCLUDE
+settime QUERY
+settime END
+
+gnunet-ballot-group-certify -c $CFG0 -g "test voters" -e ca -m $V0_PUB >
"$PREFIX/v0-cert"
+
+gnunet-ballot -c $CFG0 -i -e issuer "$PREFIX/ballot"
+
+# FIXME: daemon should be started with arm
+gnunet-daemon-ballot-tally -c $CFG0 &
+
+sleep 5
+
+gnunet-ballot -c $CFG0 -r "$PREFIX/ballot"
+
+gnunet-ballot -c $CFG0 -g "$PREFIX/v0-cert" "$PREFIX/ballot"
+
+gnunet-ballot -c $CFG0 -x yes "$PREFIX/ballot" -e voter0
+
+NOW=$(date +%s)
+
+if [[ $NOW -lt $TS_START ]]; then
+ T=$((TS_START - NOW))
+ echo sleeping $T s until start
+ sleep $((TS_START - NOW))
+fi
+
+if [[ $NOW -ge $TS_CLOSING ]]; then
+ echo "we are to slow, ballot already closed"
+ echo "now: $NOW, closing: $TS_CLOSING"
+ exit 1
+fi
+
+
+gnunet-ballot -c $CFG0 -s "$PREFIX/ballot"
+
+NOW=$(date +%s)
+
+if [[ $NOW -lt $TS_QUERY ]]; then
+ T=$((TS_QUERY - NOW))
+ echo sleeping $T s until query
+ sleep $((TS_QUERY - NOW))
+fi
+
+gnunet-ballot -c $CFG0 -q "$PREFIX/ballot"
+
+# check validity
+#gnunet-ballot -V "$PREFIX/ballot"
+
+
Property changes on: gnunet-java/src/test/bash/test_voting_simple.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: gnunet-java/tools/build
===================================================================
--- gnunet-java/tools/build 2013-10-28 16:37:04 UTC (rev 30445)
+++ gnunet-java/tools/build 2013-10-29 02:37:48 UTC (rev 30446)
@@ -9,7 +9,7 @@
# exit when something goes wrong!
set -e
-BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
+SDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OUTDIR="$BASEDIR/build/"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30446 - in gnunet-java: . bin src/main/java/org/gnunet/mesh src/main/java/org/gnunet/util src/main/java/org/gnunet/util/crypto src/main/java/org/gnunet/voting src/main/java/org/gnunet/voting/messages src/test src/test/bash tools,
gnunet <=