Skip to content

Commit

Permalink
Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Aug 28, 2020
1 parent 4648aa0 commit 843bba7
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/ChannelGlobals.java
Expand Up @@ -3,7 +3,7 @@

public class ChannelGlobals
{
public static final String VERSION = "v0.6.0-2020.08.27.02";
public static final String VERSION = "v0.6.0-2020.08.28.00";

public static final String USER_ADDRESS_STRING="user";
public static final String NODE_ADDRESS_STRING="node";
Expand Down
44 changes: 22 additions & 22 deletions test/ChannelDataTest.java
Expand Up @@ -38,9 +38,9 @@ public void testChannelData()

WalletDatabase admin_db = TestUtil.genWallet();
ChannelID chan_id = null;
ChainHash prev_hash = null;
ChainHash prev_hash = null;

ChannelContext ctx_a;
ChannelContext ctx_a;


TreeMap<String, ByteString> data_map = new TreeMap<>();
Expand All @@ -63,15 +63,15 @@ public void testChannelData()
header.setChannelId( chan_id.getBytes());
header.setPrevBlockHash( ChainHash.ZERO_HASH.getBytes());
header.setContentMerkle( ChainHash.ZERO_HASH.getBytes());

ChannelBlock.Builder blk = ChannelBlock.newBuilder();
blk.setSignedHeader( ChannelSigUtil.signMessage(admin_db.getAddresses(0), admin_db.getKeys(0),
SignedMessagePayload.newBuilder().setChannelBlockHeader(header.build()).build()));
ctx_a = node_a.getChannelSubscriber().openChannel(chan_id);
prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());
ctx_a = node_a.getChannelSubscriber().openChannel(chan_id);
prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());
}

for(int i=0; i<20; i++)
Expand All @@ -84,7 +84,7 @@ public void testChannelData()
header.setPrevBlockHash( prev_hash.getBytes());

ChannelBlock.Builder blk = ChannelBlock.newBuilder();
LinkedList<ChainHash> merkle_list = new LinkedList<>();
for(int j=0; j<20; j++)
{
Expand All @@ -97,27 +97,27 @@ public void testChannelData()
blk.setSignedHeader( ChannelSigUtil.signMessage(admin_db.getAddresses(0), admin_db.getKeys(0),
SignedMessagePayload.newBuilder().setChannelBlockHeader(header.build()).build()));

prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());
prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());

for(String key : data_map.keySet())
{
Assert.assertEquals( data_map.get(key), ChanDataUtils.getData(ctx_a, key));
}
for(String key : data_map.keySet())
{
Assert.assertEquals( data_map.get(key), ChanDataUtils.getData(ctx_a, key));
}

}

Assert.assertEquals(20, ctx_a.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(20, ctx_a.block_ingestor.getHead().getHeader().getBlockHeight());

}

private ChannelNode startNode()
private ChannelNode startNode()
throws Exception
{
{
File base_dir = test_folder.newFolder();
TreeMap<String,String> map = new TreeMap<>();
map.put("key_count", "1");
map.put("db_separate", "true");
map.put("db_separate", "true");
map.put("db_path", new File(base_dir, "db").getPath());
map.put("wallet_path", new File(base_dir, "wallet").getPath());

Expand All @@ -129,7 +129,7 @@ private ChannelNode startNode()

return new ChannelNode(new ConfigMem(map));

}
}
protected AddressSpecHash getAddr(WalletDatabase db)
{
return AddressUtil.getHashForSpec(db.getAddresses(0));
Expand All @@ -153,16 +153,16 @@ protected SignedMessage randomDataContent(WalletDatabase user, Map<String, ByteS
ci.setContent( ByteString.copyFrom(b));
}

for(int i=0;i<20; i++)
{
for(int i=0;i<20; i++)
{
String key = "/chantestdata/" + rnd.nextLong();
b = new byte[32];
rnd.nextBytes(b);

ci.putChanMapUpdates(key, ByteString.copyFrom(b));
data_map.put(key, ByteString.copyFrom(b));

}
}

WalletDatabase wdb = user;
return ChannelSigUtil.signMessage( wdb.getAddresses(0),wdb.getKeys(0),
Expand Down
38 changes: 19 additions & 19 deletions test/ChannelPeerTest.java
Expand Up @@ -67,9 +67,9 @@ public void testChannelPeerAndSync()
WalletDatabase admin_db = TestUtil.genWallet();
WalletDatabase user_db = TestUtil.genWallet();
ChannelID chan_id = null;
ChainHash prev_hash = null;
ChainHash prev_hash = null;

ChannelContext ctx_a;
ChannelContext ctx_a;
ChannelContext ctx_b;
ChannelContext ctx_c;

Expand All @@ -96,15 +96,15 @@ public void testChannelPeerAndSync()
ChannelBlock.Builder blk = ChannelBlock.newBuilder();
blk.setSignedHeader( ChannelSigUtil.signMessage(admin_db.getAddresses(0), admin_db.getKeys(0),
SignedMessagePayload.newBuilder().setChannelBlockHeader(header.build()).build()));
ctx_a = node_a.getChannelSubscriber().openChannel(chan_id);
Thread.sleep(500);
ctx_b = node_b.getChannelSubscriber().openChannel(chan_id);
ctx_c = node_c.getChannelSubscriber().openChannel(chan_id);
ctx_a = node_a.getChannelSubscriber().openChannel(chan_id);
Thread.sleep(500);
ctx_b = node_b.getChannelSubscriber().openChannel(chan_id);
ctx_c = node_c.getChannelSubscriber().openChannel(chan_id);

prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());

ctx_a.block_ingestor.ingestBlock(blk.build());
ctx_a.block_ingestor.ingestBlock(blk.build());
}

for(int i=0; i<20; i++)
Expand All @@ -131,8 +131,8 @@ public void testChannelPeerAndSync()
blk.setSignedHeader( ChannelSigUtil.signMessage(admin_db.getAddresses(0), admin_db.getKeys(0),
SignedMessagePayload.newBuilder().setChannelBlockHeader(header.build()).build()));

prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());
prev_hash = new ChainHash(blk.getSignedHeader().getMessageId());
ctx_a.block_ingestor.ingestBlock(blk.build());

for(ContentChunk c : large_chunks)
{
Expand All @@ -142,7 +142,7 @@ public void testChannelPeerAndSync()
}

Assert.assertEquals(0, ChunkMapUtils.getWantList(ctx_a).size());
Assert.assertEquals(20, ctx_a.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(20, ctx_a.block_ingestor.getHead().getHeader().getBlockHeight());

for(int i=0; i<100; i++)
{
Expand All @@ -166,20 +166,20 @@ public void testChannelPeerAndSync()
}
}

Assert.assertEquals(20, ctx_b.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(20, ctx_b.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(0, ChunkMapUtils.getWantList(ctx_b).size());

Assert.assertEquals(20, ctx_c.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(20, ctx_c.block_ingestor.getHead().getHeader().getBlockHeight());
Assert.assertEquals(0, ChunkMapUtils.getWantList(ctx_c).size());
}

private ChannelNode startNode()
private ChannelNode startNode()
throws Exception
{
{
File base_dir = test_folder.newFolder();
TreeMap<String,String> map = new TreeMap<>();
map.put("key_count", "1");
map.put("db_separate", "true");
map.put("db_separate", "true");
map.put("db_path", new File(base_dir, "db").getPath());
map.put("wallet_path", new File(base_dir, "wallet").getPath());

Expand All @@ -191,7 +191,7 @@ private ChannelNode startNode()

return new ChannelNode(new ConfigMem(map));

}
}
protected AddressSpecHash getAddr(WalletDatabase db)
{
return AddressUtil.getHashForSpec(db.getAddresses(0));
Expand Down Expand Up @@ -224,7 +224,7 @@ protected SignedMessage randomContent(WalletDatabase wdb, List<ContentChunk> lar
{
ci.setContent( data);
}
else
else
{
MessageDigest md = DigestUtil.getMD();
for(int chunk = 0; chunk*ChannelGlobals.CONTENT_DATA_BLOCK_SIZE < len; chunk++)
Expand Down
2 changes: 1 addition & 1 deletion test/ChannelTest.java
Expand Up @@ -25,7 +25,7 @@ public static void loadProvider()
Globals.addCryptoProvider();
}

@Test
@Test
public void testChannelDB()
throws Exception
{
Expand Down
2 changes: 1 addition & 1 deletion test/ChannelValidationTest.java
Expand Up @@ -24,7 +24,7 @@ public static void loadProvider()
Globals.addCryptoProvider();
}

@Test
@Test
public void testChannelValidateGood()
throws Exception
{
Expand Down
8 changes: 4 additions & 4 deletions test/ChunkMapUtilsTest.java
Expand Up @@ -29,11 +29,11 @@ public static void loadProvider()
}


@Test
public void testChunkMap()
throws Exception
@Test
public void testChunkMap()
throws Exception
{
ChannelNode node = startNode();
ChannelNode node = startNode();
Random rnd = new Random();

byte[] b = new byte[20];
Expand Down
62 changes: 31 additions & 31 deletions test/CipherChannelTest.java
Expand Up @@ -60,54 +60,54 @@ public void testCipherChannel()
ChannelNode node_c = startNode("rocksdb", false, webport_c);
ChannelNode node_d = startNode("rocksdb", false, webport_d);

ChannelID cid = BlockGenUtils.createChannel(node_a, node_a.getUserWalletDB(), "cipher-test");
ChannelID cid = BlockGenUtils.createChannel(node_a, node_a.getUserWalletDB(), "cipher-test");

ChannelAccess a_a = new ChannelAccess(node_a, node_a.getChannelSubscriber().openChannel(cid));
ChannelAccess a_b = new ChannelAccess(node_b, node_b.getChannelSubscriber().openChannel(cid));
ChannelAccess a_c = new ChannelAccess(node_c, node_c.getChannelSubscriber().openChannel(cid));
ChannelAccess a_d = new ChannelAccess(node_d, node_d.getChannelSubscriber().openChannel(cid));

ChannelContext ctx_a = node_a.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_b = node_b.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_c = node_c.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_d = node_c.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_a = node_a.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_b = node_b.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_c = node_c.getChannelSubscriber().openChannel(cid);
ChannelContext ctx_d = node_c.getChannelSubscriber().openChannel(cid);

File file_dir = test_folder.newFolder();

{
JsonFormat.Printer printer = JsonFormat.printer();
EncryptedChannelConfig.Builder conf = EncryptedChannelConfig.newBuilder();
conf.setProtectedPath("/prot/");
PrintStream file_out = new PrintStream(new FileOutputStream(new File(file_dir, "encryption.json")));

file_out.println(printer.print(conf.build()));
file_out.close();
JsonFormat.Printer printer = JsonFormat.printer();
EncryptedChannelConfig.Builder conf = EncryptedChannelConfig.newBuilder();
conf.setProtectedPath("/prot/");
PrintStream file_out = new PrintStream(new FileOutputStream(new File(file_dir, "encryption.json")));

file_out.println(printer.print(conf.build()));
file_out.close();
}


Assert.assertNull(ChannelCipherUtils.getCommonKeyID(ctx_a));
Assert.assertNull(ChannelCipherUtils.getCommonKeyID(ctx_a));

a_a.createBlockForFiles(file_dir);
//ChannelCipherUtils.establishCommonKey(node_a, ctx_a);
//ChannelCipherUtils.establishCommonKey(node_a, ctx_a);

Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_a));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_a));

ChannelCipherUtils.addKeys(node_a, ctx_a, ImmutableList.of(node_b.getUserWalletDB().getAddresses(0)));
ChannelCipherUtils.addKeys(node_a, ctx_a, ImmutableList.of(node_b.getUserWalletDB().getAddresses(0)));

WalletKeyPair node_d_key = ChannelCipherUtils.getKeyForChannel(cid, node_d.getUserWalletDB());
AddressSpec spec_d = AddressUtil.getSimpleSpecForKey(node_d_key);
ChannelCipherUtils.addKeys(node_a, ctx_a, ImmutableList.of(spec_d));
ChannelCipherUtils.addKeys(node_a, ctx_a, ImmutableList.of(spec_d));

String key_id = ChannelCipherUtils.getCommonKeyID(ctx_a);
String key_id = ChannelCipherUtils.getCommonKeyID(ctx_a);


TreeMap<String, ChainHash> plain_file_map = new TreeMap<>();
TreeMap<String, ChainHash> prot_file_map = new TreeMap<>();

for(int i=0; i<FILES_TO_SYNC; i++)
{
int sz = rnd.nextInt(MAX_FILE_SIZE);
int sz = rnd.nextInt(MAX_FILE_SIZE);
byte[] buff = new byte[sz];
rnd.nextBytes(buff);

Expand All @@ -129,7 +129,7 @@ public void testCipherChannel()

for(int i=0; i<FILES_TO_SYNC; i++)
{
int sz = rnd.nextInt(MAX_FILE_SIZE);
int sz = rnd.nextInt(MAX_FILE_SIZE);
byte[] buff = new byte[sz];
rnd.nextBytes(buff);

Expand Down Expand Up @@ -169,15 +169,15 @@ public void testCipherChannel()
Thread.sleep(1000);
}

Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_a));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_b));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_c));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_d));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_a));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_b));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_c));
Assert.assertNotNull(ChannelCipherUtils.getCommonKeyID(ctx_d));

Assert.assertNotNull(ChannelCipherUtils.getKeyFromChannel(ctx_a, key_id, node_a.getUserWalletDB().getKeys(0)));
Assert.assertNotNull(ChannelCipherUtils.getKeyFromChannel(ctx_b, key_id, node_b.getUserWalletDB().getKeys(0)));
Assert.assertNull(ChannelCipherUtils.getKeyFromChannel(ctx_c, key_id, node_c.getUserWalletDB().getKeys(0)));
Assert.assertNull(ChannelCipherUtils.getKeyFromChannel(ctx_d, key_id, node_d.getUserWalletDB().getKeys(0)));
Assert.assertNotNull(ChannelCipherUtils.getKeyFromChannel(ctx_a, key_id, node_a.getUserWalletDB().getKeys(0)));
Assert.assertNotNull(ChannelCipherUtils.getKeyFromChannel(ctx_b, key_id, node_b.getUserWalletDB().getKeys(0)));
Assert.assertNull(ChannelCipherUtils.getKeyFromChannel(ctx_c, key_id, node_c.getUserWalletDB().getKeys(0)));
Assert.assertNull(ChannelCipherUtils.getKeyFromChannel(ctx_d, key_id, node_d.getUserWalletDB().getKeys(0)));

for(String name : plain_file_map.keySet())
{
Expand All @@ -196,7 +196,7 @@ public void testCipherChannel()
Assert.assertEquals( hash, download(webport_d, cid, "prot/" + name));
}

}
}

private ChannelNode startNode(String db_type, boolean skip_seeds, int webport)
throws Exception
Expand Down Expand Up @@ -227,7 +227,7 @@ protected ChainHash download(int webport, ChannelID cid, String filename)
throws Exception
{

String url = "http://localhost:" + webport + "/channel/" + cid + "/" + filename;
String url = "http://localhost:" + webport + "/channel/" + cid + "/" + filename;
long start_t = System.currentTimeMillis();
System.out.println(url);
URL u = new URL(url);
Expand Down
6 changes: 3 additions & 3 deletions test/DHTTest.java
Expand Up @@ -128,9 +128,9 @@ public void testDHTReadWrite()
Assert.assertTrue(c_match > 60);
}

private ChannelNode startNode(String db_type, boolean skip_seeds)
private ChannelNode startNode(String db_type, boolean skip_seeds)
throws Exception
{
{
File base_dir = test_folder.newFolder();
TreeMap<String,String> map = new TreeMap<>();
map.put("key_count", "1");
Expand All @@ -151,6 +151,6 @@ private ChannelNode startNode(String db_type, boolean skip_seeds)

return new ChannelNode(new ConfigMem(map));

}
}

}

0 comments on commit 843bba7

Please sign in to comment.