public BaseContract LoadContract(Address address)
            {
                if (address == this.integration.contractRegistryAddress)
                {
                    throw new ArgumentOutOfRangeException(address + " is a magic address which cannot be used for contracts.");
                }

                var data = this.LoadData(address);

                this.integration.logger.LogTrace("Received contract data: " + data.Length + " bytes for " + address);

                if (data.Length == 0)
                {
                    if (address == KitContract.DefaultAddress)
                    {
                        data = this.integration.initialKitFallback;
                    }
                    else
                    {
                        return(new NonexistentContract());
                    }
                }

                return((BaseContract)StrongForceSerialization.DeserializeStatefulObject(data));
            }
        public void Serializes_And_Deserializes_Contracts()
        {
            var address      = new Address(new byte[] { 10, 20, 127, 54, 51 });
            var adminAddress = new Address(new byte[] { 10, 20, 4 });
            var contract     = StatefulObject.Create <FavoriteNumberContract>(new Dictionary <string, object> {
                { "Admin", adminAddress.ToString() }, { "Number", 15 }
            });

            contract.RegisterWithRegistry(new InMemoryIntegration.FakeContractContext(address));

            var serializedContract = StrongForceSerialization.SerializeStatefulObject(contract);

            var deserializedContract = (FavoriteNumberContract)StrongForceSerialization.DeserializeStatefulObject(serializedContract);

            deserializedContract.RegisterWithRegistry(new InMemoryIntegration.FakeContractContext(address));

            Assert.Equal(contract.GetState(), deserializedContract.GetState());
            Assert.Equal(contract.Address, deserializedContract.Address);
            Assert.Equal(contract.Number, deserializedContract.Number);
        }