# Factory Test

Testing if XdYe Factory can create Pairs for different tokens, in this case we are going to try to create the following pairs:

* Token A - XdYe Token
* XdYe Token - wETH
* Token A - wETH

The script used for testing this capability: *(1)*&#x20;

{% embed url="<https://github.com/rogerCapone/XdYe_Tests/blob/main/Factory_CreatePairOnXdYe.js>" %}
Create Pair on Factory contract
{% endembed %}

Once we are building the DEX, or better said, when we want to create uniqueness and allow Router to correctly operate, we will need to define init code hash, in the factory testing we need to check if we are able to retrieve the INIT\_CODE\_PAIR\_HASH variable.

The script used for testing this capability: *(2)*

{% embed url="<https://github.com/rogerCapone/XdYe_Tests/blob/main/Factory_GetInitPairCodeHash.js>" %}
Retrieve  INIT\_CODE\_PAIR\_HASH from Factory contract
{% endembed %}

We can also test if the XdYe Factory smart contract will revert transaction if we try to create a pair that has already been created. In this case we will just need to run the script *(1)* for a second time, then the expected behaviour is the script to fail.

Finally will just need to ensure that the XdYe Factory contract can modify the FeeTo variable and also the one allowed to modify the FeeToSetter. The difference between those variables:

* **FeeTo:** Address that receives the LPs obtained from Trading Fees on XdYe.
* **FeeToSetter:** Address that has the capability to modify the FeeTo variable (who receives the XdYe trading Fees).

The script used for testing this capability: *(3)*

{% embed url="<https://github.com/rogerCapone/XdYe_Tests/blob/main/Factory_checkFeesEdits.js>" %}
Check if setFeeTo and setFeeToSetter work correctly on Factory contract
{% endembed %}
