Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rustyrussell/pettycoin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fd1838962fb1
Choose a base ref
...
head repository: rustyrussell/pettycoin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 063903453ee7
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 9, 2014

  1. pettycoin-gateway: record transactions after we've injected them.

    Stupid bug keeps us reinjecting the same txs over and over!
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 9, 2014
    Copy the full SHA
    e8839a3 View commit details
  2. pettycoin-gateway: clean up htable on freeing ctx.

    Useful for testing for leaks under valgrind.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 9, 2014
    Copy the full SHA
    0aacade View commit details
  3. pettycoin-gateway: simple test.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Sep 9, 2014
    Copy the full SHA
    0639034 View commit details
Showing with 727 additions and 4 deletions.
  1. +17 −4 pettycoin-gateway.c
  2. +2 −0 test/.gitignore
  3. +708 −0 test/run-20-gateway.c
21 changes: 17 additions & 4 deletions pettycoin-gateway.c
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ decoderawtransaction 0100000001362ba4199d822ed6bc5a44885f85f0053a1ebd2582da59b1e
}
*/

#ifndef TESTING
static bool get_lock(int fd)
{
struct flock fl;
@@ -227,6 +228,7 @@ static char *ask_process(const tal_t *ctx,

return output;
}
#endif /* !TESTING */

static char *ask_bitcoind(const tal_t *ctx,
const char *req,
@@ -472,13 +474,18 @@ static bool pettycoin_tx(const tal_t *ctx, const char *privkey,
return true;
}

static void destroy_thash(struct thash *thash)
{
thash_clear(thash);
}

int main(int argc, char *argv[])
{
tal_t *ctx = tal(NULL, char);
const char *privkey;
char *pettycoin_dir, *rpc_filename;
bool setup = false;
struct thash thash;
struct thash *thash;
int fd;

err_set_progname(argv[0]);
@@ -508,8 +515,10 @@ int main(int argc, char *argv[])
exit(0);
}

thash_init(&thash);
fd = read_gateway_txs(&thash);
thash = tal(ctx, struct thash);
tal_add_destructor(thash, destroy_thash);
thash_init(thash);
fd = read_gateway_txs(thash);
privkey = grab_file(ctx, "gateway-privkey");
if (!privkey)
err(1, "Reading gateway-privkey");
@@ -579,7 +588,7 @@ int main(int argc, char *argv[])
json_tok_contents(buffer, val));

/* Do we already know it? */
if (thash_get(&thash, &txid))
if (thash_get(thash, &txid))
continue;

amount = json_get_member(buffer, t, "amount");
@@ -606,6 +615,10 @@ int main(int argc, char *argv[])
if (!write_all(fd, &txid, sizeof(txid)))
err(1, "Writing out txid");

/* Add to hash so we don't get it again next time. */
thash_add(thash,
tal_dup(ctx, struct protocol_double_sha, &txid,
1, 0));
}
/* Clean up. */
tal_free(this_ctx);
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
run-01-base16
run-01-base58
run-01-create_gateway_transaction
run-01-difficulty
@@ -17,4 +18,5 @@ run-07-block_swizzle
run-08-simple-chain
run-08-tx_shard
run-09-chain
run-20-gateway
easy_genesis.c
708 changes: 708 additions & 0 deletions test/run-20-gateway.c

Large diffs are not rendered by default.