Context:
To test the application layer of LightChain, we need to mock out the RMI underlay implementation. However, we are not going to rely on the java-generated mock for this purpose. Rather, we are going to extend an instance of Underlay interface that keeps an inventory of all created underlays, and directly exchange messages between them:
public class MockUnderlay extends Underlay {
private static HashMap<String, MockUnderlay> inventory;
public MockUnderlay(String myAddress){
inventory.put(myAddress, this);
}
@Override
public GenericResponse sendMessage(GenericRequest req, String targetAddress) throws RemoteException, FileNotFoundException {
try {
return inventory.get(targetAddress).answer(req);
} catch (NullPointerException e) {
throw new RemoteException("target address not found");
} catch (Exception e){
// we should terminate if any other issue happened.
}
}
@Override
public boolean terminate() {
return true;
}
public GenericResponse answer(GenericRequest req){
// Here we address answering the generic request.
}
}
Note: MockUnderlay should be implemented in src/main/java/underlay/mock/mockUnderlay.java.
Test Cases:
Test cases we should cover:
- When both underlays A and B are up and ready, their exchanged messages are delivered to each other intact.
- When A is down, B sending a message to A is gracefully notified of unsuccessful delivery. Here, by a graceful delivery we mean through a returned parameter or state variable, and without interfering with the normal flow of the program, throwing an exception, or causing to crash.
- Above test cases also covered for multiple messages being sent both sequentially and concurrently.
Definition of Done:
-
Definition of Done:
- We have an
Underlay interface that abstracts away the entire networking primitives.
- The only functionality that LightChain protocol is aware of networking is this new
Underlay interface.
Underlay is implemented at the broadest level of abstraction with minimum endpoints basically sending and receiving messages of general types. As a general rule, Underlay in LightChain should not have any more number of methods than Underlay in Skip Graph project.
- New functionalities completely covered by tests.
Development rules:
- Fork a branch in the form of
yourname/issuenumber-issuetopic from master.
- Develop on the branch.
- Make sure that your code is well-commented, documented, supported by tests, and clean.
- The code should not add any commented functionality. If you comment something out, it means that you should completely remove it.
- Open the PR and make sure that it passes the pipeline.
- Important note: Your PR should not change more than 200 lines of code. If the surface of your PR is large, please break it into smaller ones, each completely passing the CI pipeline and able to merge, and open them one-by-one, i.e., open the first micro-PR, let it be reviewed and merge, and go with the second.
Context:
To test the application layer of LightChain, we need to mock out the RMI underlay implementation. However, we are not going to rely on the java-generated mock for this purpose. Rather, we are going to extend an instance of
Underlayinterface that keeps an inventory of all created underlays, and directly exchange messages between them:Note:
MockUnderlayshould be implemented insrc/main/java/underlay/mock/mockUnderlay.java.Test Cases:
Test cases we should cover:
Definition of Done:
Definition of Done:
Underlayinterface that abstracts away the entire networking primitives.Underlayinterface.Underlayis implemented at the broadest level of abstraction with minimum endpoints basically sending and receiving messages of general types. As a general rule, Underlay in LightChain should not have any more number of methods than Underlay in Skip Graph project.Development rules:
yourname/issuenumber-issuetopicfrom master.