@@ -0,0 +1,2240 @@
+package peergos.server.tests;%0A%0Aimport org.junit.*;%0Aimport org.junit.runner.*;%0Aimport org.junit.runners.*;%0Aimport peergos.server.sql.*;%0Aimport peergos.server.storage.*;%0Aimport peergos.server.util.*;%0Aimport peergos.shared.crypto.hash.*;%0Aimport peergos.shared.io.ipfs.cid.*;%0Aimport peergos.shared.io.ipfs.multihash.*;%0Aimport peergos.shared.storage.*;%0A%0Aimport java.security.*;%0Aimport java.util.*;%0A%0A@RunWith(Parameterized.class)%0Apublic class TransactionsStoreTests %7B%0A%0A    private final TransactionStore store;%0A%0A    public TransactionsStoreTests(TransactionStore store) %7B%0A        this.store = store;%0A    %7D%0A%0A    @Parameterized.Parameters()%0A    public static Collection%3CObject%5B%5D%3E parameters() throws Exception %7B%0A        TransactionStore ram = JdbcTransactionStore.build(Sqlite.build(%22:memory:%22), new SqliteCommands());%0A        return Arrays.asList(new Object%5B%5D%5B%5D %7B%0A                %7Bram%7D%0A        %7D);%0A    %7D%0A%0A    public static byte%5B%5D hash(byte%5B%5D input) %7B%0A        try %7B%0A            MessageDigest md = MessageDigest.getInstance(%22SHA-256%22);%0A            md.update(input);%0A            return md.digest();%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            throw new IllegalStateException(%22couldn't find hash algorithm%22);%0A        %7D%0A    %7D%0A%0A    public static Cid hashToCid(byte%5B%5D input, boolean isRaw) %7B%0A        byte%5B%5D hash = hash(input);%0A        return new Cid(1, isRaw ? Cid.Codec.Raw : Cid.Codec.DagCbor, Multihash.Type.sha2_256, hash);%0A    %7D%0A%0A    @Test%0A    public void singleTransaction() %7B%0A        Cid multihash = hashToCid(new byte%5B2%5D, true);%0A        PublicKeyHash owner = new PublicKeyHash(multihash);%0A        TransactionId tid = store.startTransaction(owner);%0A        List%3CMultihash%3E pending = new ArrayList%3C%3E();%0A        for (int i=0; i %3C 20; i++) %7B%0A            Cid block = hashToCid(new byte%5B%5D%7B(byte) i%7D, false);%0A            pending.add(block);%0A            store.addBlock(block, tid, owner);%0A        %7D%0A        List%3CMultihash%3E uncommitted = store.getOpenTransactionBlocks();%0A        Assert.assertTrue(%22All blocks present%22, uncommitted.containsAll(pending));%0A%0A        store.closeTransaction(owner, tid);%0A        List%3CMultihash%3E empty = store.getOpenTransactionBlocks();%0A        Assert.assertTrue(%22All blocks removed%22, empty.isEmpty());%0A    %7D%0A%7D%0A

Add a transaction store test