/** * Tests that duplicate operations are a no-op. * * @throws Exception should not be thrown. */ public void testDuplicateOperations() throws Exception { assertEquals(0L, wavelet.getCurrentVersion().getVersion()); // create the wavelet. WaveletDeltaRecord v0Response = wavelet.submitRequest( WAVELET_NAME, createProtocolSignedDelta(addParticipantOp, HASHED_VERSION_ZERO)); assertEquals(1L, wavelet.getCurrentVersion().getVersion()); ProtocolSignedDelta psd = createProtocolSignedDelta( addBlipOp, v0Response.getResultingVersion()); WaveletDeltaRecord dar1 = wavelet.submitRequest(WAVELET_NAME, psd); assertEquals(2L, wavelet.getCurrentVersion().getVersion()); WaveletDeltaRecord dar2 = wavelet.submitRequest(WAVELET_NAME, psd); assertEquals(2L, wavelet.getCurrentVersion().getVersion()); assertEquals(dar1.getResultingVersion(), dar2.getResultingVersion()); }
/** * Tests that duplicate operations are a no-op. * * @throws Exception should not be thrown. */ public void testDuplicateOperations() throws Exception { assertEquals(0L, wavelet.getCurrentVersion().getVersion()); // create the wavelet. WaveletDeltaRecord v0Response = wavelet.submitRequest( WAVELET_NAME, createProtocolSignedDelta(addParticipantOp, HASHED_VERSION_ZERO)); assertEquals(1L, wavelet.getCurrentVersion().getVersion()); ProtocolSignedDelta psd = createProtocolSignedDelta( addBlipOp, v0Response.getResultingVersion()); WaveletDeltaRecord dar1 = wavelet.submitRequest(WAVELET_NAME, psd); assertEquals(2L, wavelet.getCurrentVersion().getVersion()); WaveletDeltaRecord dar2 = wavelet.submitRequest(WAVELET_NAME, psd); assertEquals(2L, wavelet.getCurrentVersion().getVersion()); assertEquals(dar1.getResultingVersion(), dar2.getResultingVersion()); }
public void testLocalEmptyDelta() throws Exception { ProtocolSignedDelta emptyDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature1) .setDelta(ProtocolWaveletDelta.newBuilder() .setAuthor(author.toString()) .setHashedVersion(serialize(localVersion0)) .build().toByteString()) .build(); try { localWavelet.submitRequest(localWaveletName, emptyDelta); fail("Should fail"); } catch (IllegalArgumentException e) { // Correct } }
public void testLocalEmptyDelta() throws Exception { ProtocolSignedDelta emptyDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature1) .setDelta(ProtocolWaveletDelta.newBuilder() .setAuthor(author.toString()) .setHashedVersion(serialize(localVersion0)) .build().toByteString()) .build(); try { localWavelet.submitRequest(localWaveletName, emptyDelta); fail("Should fail"); } catch (IllegalArgumentException e) { // Correct } }
.build(); try { localWavelet.submitRequest(localWaveletName, removeDelta); fail("Should fail"); } catch (OperationException e) { .build(); localWavelet.submitRequest(localWaveletName, addDelta); try { ProtocolSignedDelta addAgainDelta = ProtocolSignedDelta.newBuilder() .build().toByteString()) .build(); localWavelet.submitRequest(localWaveletName, addAgainDelta); fail("Should fail"); } catch (OperationException e) { .build(); try { localWavelet.submitRequest(localWaveletName, rollbackDelta); fail("Should fail"); } catch (OperationException e) {
.build(); try { localWavelet.submitRequest(localWaveletName, removeDelta); fail("Should fail"); } catch (OperationException e) { .build(); localWavelet.submitRequest(localWaveletName, addDelta); try { ProtocolSignedDelta addAgainDelta = ProtocolSignedDelta.newBuilder() .build().toByteString()) .build(); localWavelet.submitRequest(localWaveletName, addAgainDelta); fail("Should fail"); } catch (OperationException e) { .build(); try { localWavelet.submitRequest(localWaveletName, rollbackDelta); fail("Should fail"); } catch (OperationException e) {
public void testSuccessfulLocalRequest() throws Exception { ProtocolSignedDelta addDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature1) .setDelta(addParticipantProtoDelta(localWavelet).toByteString()) .build(); localWavelet.submitRequest(localWaveletName, addDelta); assertEquals(localWavelet.getCurrentVersion().getVersion(), 2); assertTrue(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner1)); assertFalse(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner2)); HashedVersion oldVersion = localWavelet.getCurrentVersion(); ProtocolSignedDelta removeDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature2) .setDelta(ProtocolWaveletDelta.newBuilder(removeParticipantProtoDelta(localWavelet)) .setHashedVersion(serialize(localWavelet.getCurrentVersion())).build().toByteString()) .build(); localWavelet.submitRequest(localWaveletName, removeDelta); assertEquals(localWavelet.getCurrentVersion().getVersion(), 4); assertTrue(localWavelet.isDeltaSigner(oldVersion, fakeSigner1)); assertFalse(localWavelet.isDeltaSigner(oldVersion, fakeSigner2)); assertTrue(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner2)); assertFalse(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner1)); }
public void testSuccessfulLocalRequest() throws Exception { ProtocolSignedDelta addDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature1) .setDelta(addParticipantProtoDelta(localWavelet).toByteString()) .build(); localWavelet.submitRequest(localWaveletName, addDelta); assertEquals(localWavelet.getCurrentVersion().getVersion(), 2); assertTrue(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner1)); assertFalse(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner2)); HashedVersion oldVersion = localWavelet.getCurrentVersion(); ProtocolSignedDelta removeDelta = ProtocolSignedDelta.newBuilder() .addSignature(fakeSignature2) .setDelta(ProtocolWaveletDelta.newBuilder(removeParticipantProtoDelta(localWavelet)) .setHashedVersion(serialize(localWavelet.getCurrentVersion())).build().toByteString()) .build(); localWavelet.submitRequest(localWaveletName, removeDelta); assertEquals(localWavelet.getCurrentVersion().getVersion(), 4); assertTrue(localWavelet.isDeltaSigner(oldVersion, fakeSigner1)); assertFalse(localWavelet.isDeltaSigner(oldVersion, fakeSigner2)); assertTrue(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner2)); assertFalse(localWavelet.isDeltaSigner( localWavelet.getCurrentVersion(), fakeSigner1)); }