Waffle Fixtures via Ethers - ethereum

As listed in the Waffle documentation, we can create fixtures. How do I do this if I want to use ethers instead of web3? Are there any ways to create mock provider via ethers?

Related

How do I pass an environment variable into a foundry test file?

Looking to pass an alchemy rpc endpoint url that contains its api key and is stored as an environment variable in a solidity test file executed using forge test. I want to do so in order to use it to fork goerli testnet and potentially be able to manage different forks in the same test context. The vm cheatcode below creates a local fork of goerli at block_number:
vm.createSelectFork($GOERLI_ALCHEMY_SECRET_URL, block_number);
How do I pass it $GOERLI_ALCHEMY_SECRET_URL from the environment?
In order to pass an environment variable into a test file you can make use of vm.envString():
vm.createSelectFork(vm.envString("GOERLI_ALCHEMY_SECRET_URL"), block_number);

Spring Cloud Contract Setting `stubsMode` at runtime

We're using Spring Cloud Contract for testing our services. I was wondering if there is some way to set the stubsMode at runtime, as opposed to being an option on the annotation:
#AutoConfigureStubRunner(ids = {...}, stubsMode = StubRunnerProperties.StubsMode.LOCAL)
If the annotation is the only way to set this option, we'll need to have two separate classes, one for local and one for remote.
You can use the properties. We describe it in the docs. Just pass the system prop stubrunner.stubs-mode=local or an env var STUBRUNNER_STUBS_MODE=LOCAL

junit test class always be one to one with the classes of a program

I have a implementation class which fetches items from dynamo db and the dynamo table has S3 url as one of its column value. The implementation class call this helper to get the content from S3.
Should we write junits for the individual files or in this cases junit for implementation class would be sufficient allowing impl class to call helper class and mocked the call to S3 ?
Depends on what you're going to cover with your tests.
If the utility class is also your implementation, go cover it with an individual test.
If it is provided by some external library, testing should occur within the project of this library.

Delete the backing Lambda function for a Lambda-backed custom resource

I have an AWS CloudFormation template that creates an OpsWorks stack and deploys an application. To deploy the application, I am using a Lambda function and a custom resource which utilizes that function. My problem is: that Lambda function will only be executed one time during the creation of the stack, and then it will never be used again. Is there any way to delete the Lambda function by AWS CloudFormation at the end of the execution of the stack?
First, I should say Aditya is right, you shouldn't delete the backing Lambda as it's used throughout the lifecycle.
However, if you really really want to do it, one way is to simply have the function delete itself (and related resources, eg, role) after running.
that Lambda function will only be executed one time during the
creation of the stack, and then it will never be used again.
^^That's not the case. The backing Lambda function for a Lambda-backed custom resource will be invoked everytime the corresponding resource is touched (i.e. created, updated or deleted). AWS CloudFormation will pass RequestType parameter to that function everytime it sees that the resource is being touched, and pass it one of these values: Create, Update, Delete. Your Lambda function should perform the necessary action taking that param into account. Based on your question it appears that your Lambda function only caters to RequestType = Create?
Also, as per AWS docs, you won't be charged for creating a Lambda function, but only if you actually invoke it. So cost can't be deterring factor for keeping the function around.
On the contrary, if your concern is that you don't want extra clutter, you can try creating a common CloudFormation stack who's job will be to create shared resources, and you can then define that Lambda function over there? I'll have to know about your entire workflow to say for sure if that approach will work or not.
For what it's worth, I'd recommend not deleting the backing function of the Lambda-backed custom resource because it'll be a pain when someone touches the corresponding resource in the future, or wants to create another instance of the same resource type.
Some of your assumptions regarding custom resources are not true. In a Lambda backed custom resource, you implement your logic to support creation, update and deletion of the resource. These indications are sent from CloudFormation via the event and give you information about the stack process.
It’s important to understand the custom resource life cycle, to prevent your data from being deleted.
Create - that’s easy, when a resource is being created an event with request type Create is sent to your function.
Delete - this one is more tricky. When a resource is being deleted a Delete request type is sent. But there are more scenarios other than resource Delete. We will have to explain Update first.
Update - gets called if any of your custom resource properties were changed. For example, in our app we can modify the allowed callback urls, which will trigger the function with an Update request type
I welcome you to read more about best practices in creating custom resources in this blog post

What is the best way to pass configurations to OSGI components?

I have a set of parameters that should be configured by the user. But they are just too much to send them through RESTful services or something similar. Besides there may be another set of configurations of same parameters.
Assume that my configurations are: p1, p2, p3, ... p10
I want to make possible having more than set of initialization of these configurations such as:
(p1=x, p2=y, ... p10=1)
(p1=a, p2=b, ... p10=10)
To do that I currently implement my OSGI component with metatype=true and configurationFactory = true options so that each instance of my component will have a set of configurations initialized. Then, I process the instances in a manager component.
So the question what do you suggest for passing configurations to OSGI components from user?
Thanks
If this is really about configurations you should use the OSGi ConfigurationAdmin service. A console like the Apache Felix WebConsole can then be used to edit configurations.
If the values (or some values) can be different for each RESTful call to your application and they don't fit in a URL, you can make a POST request instead of a GET, and pass the values in the body of the request, in a suitable format.