AergoClientImpl implements AergoClient { @Override public void cacheChainIdHash(final ChainIdHash chainIdHash) { assertNotNull(chainIdHash); final Context context = contextStorage.get(); final ChainIdHashHolder chainIdHashHolder = context.get(GRPC_VALUE_CHAIN_ID_HASH_HOLDER); if (null == chainIdHashHolder) { throw new HerajException("No chain id hash holder in context"); } chainIdHashHolder.put(chainIdHash); } AergoClientImpl(final ContextStorage<Context> contextStorage); @Override ChainIdHash getCachedChainIdHash(); @Override void cacheChainIdHash(final ChainIdHash chainIdHash); @Override void close();  }
@Test public void testCacheChainIdHash() { final Context context = EmptyContext.getInstance() .withValue(GRPC_VALUE_CHAIN_ID_HASH_HOLDER, new ChainIdHashHolder()); final ContextStorage<Context> contextStorage = new UnmodifiableContextStorage(context); final AergoClientImpl aergoClient = new AergoClientImpl(contextStorage); final ChainIdHash expected = ChainIdHash.of(BytesValue.EMPTY); aergoClient.cacheChainIdHash(expected); final ChainIdHash actual = aergoClient.getCachedChainIdHash(); assertEquals(expected, actual); }